leiding

leiding

Query one json object from jsonb field

Hi,
I am stucking at get jsonb field from ecot query.
Here is the table
templates

                                           Table "public.templates"
    Column    |              Type              | Collation | Nullable |                Default
--------------+--------------------------------+-----------+----------+---------------------------------------
 id           | bigint                         |           | not null | nextval('templates_id_seq'::regclass)
 uuid         | uuid                           |           | not null |
 name         | character varying(255)         |           |          |
 state        | character varying(255)         |           |          |
 expireDate   | date                           |           |          |
 templateData | jsonb                          |           |          |
 surveys      | jsonb                          |           |          |

Here is my survey data which is a array

[
  {
    "id": "44895bb7-440f-4802-abc4-78a5bae23570",
    "data": {"age": 20, "name": "rose"},
    "updated_at": "2020-10-16T03:16:58",
    "inserted_at": "2020-10-16T03:16:58"
  }, {
    "id": "e24332e7-66d8-499c-8d49-7dfe564aa3ea",
    "data": {"age": 20, "name": "jack"},
    "updated_at": "2020-10-16T03:16:58",
    "inserted_at": "2020-10-16T03:16:58"
  }
]

I need a query which only return one survey which id == 44895bb7-440f-4802-abc4-78a5bae23570

Any idea about how to do this is pure sql or ecto?

Thanks

Most Liked

jmurphyweb

jmurphyweb

Have you checked stack overflow?

This looks like it could be relevant?

Where Next?

Popular in Questions Top

sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lists...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

Other popular topics Top

lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 29703 241
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 127536 1222
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 54250 245
New

We're in Beta

About us Mission Statement