PostgreSQL JSONB: How to get an element from Array of Embedded Documents I am comparing MongoDB with PostgreSQL query abilities. I struggle a bit with finding simple equivalent for the following MongoDB queries.  What are the equivalent commands in PostgreSQL JSONB to MongoDB's:

Single Element Satisfies the Criteria
db.inventory.find( { memos: { $elemMatch: { memo: 'on time', by: 'shipping' } } } )

Combination of Elements Satisfies the Criteria
db.inventory.find( { 'memos.memo': 'on time', 'memos.by': 'shipping' } )


From: https://docs.mongodb.org/manual/tutorial/query-documents/#array-of-embedded-documents
SELECT ($${
   "_id": 100,
   "type": "food",
   "item": "xyz",
   "qty": 25,
   "price": 2.5,
   "ratings": [ 5, 8, 9 ],
   "memos": [ { "memo": "on time", "by": "shipping" }, { "memo": "approved", "by": "billing" } ]
}$$::jsonb)@&gt;'{"memos":[{"by":"shipping"}]}';
 ?column? 
----------
 t


Note that that only works with jsonb.

You'll probably find the documentation on json indexing useful too.