



To enable subfield matching, you can pass a third parameter which is either an array of dotted paths that will be assumed The optional vars and silent arguments act the same as for jsonbpathexists. This tool implements it in SQL using a subquery, so it will likely not be the efficient on large datasets. jsonbpathqueryarray ( target jsonb, path jsonpath, vars jsonb, silent boolean ) jsonb Returns all JSON items returned by the JSON path for the specified JSON value, as a JSON array. With MongoDB, you can search a document with a subarray of objects that you want to match when any one of the elements in the array matches. Examples Languagesĭata ',to_jsonb(Cast(data->'purchases' as numeric)+2))ĭata->'age' DESC, data->'first'->'name' ASCĪdvanced Select: Match a Field Without Specifying Array Index Object containing desired ordering forceNumericSortĬast strings to number when sorting. We get this error because the query is expecting a JSON object in the WHERE clause. (anyelement) Returns the value as json or jsonb The query on line 11 can be. nvertSort(sqlField, sortQuery, ) sortQuery There are two data types in PostgreSQL for JSON: JSON and JSONB. void jsonobjectforeachmember (JsonObject object. This will create a safer query that works if the original document doesn't already exist. Indicate that the query is being used for upserting. Object containing MongoDB operations to apply to the documents. nvertUpdate(sqlField, updateQuery, ) updateQuery Note: advanced projection fields are not yet supported. Object specifying which a subset of documents to return. nvertSelect(sqlField, projectionQuery, ) projectionQuery This tool doesn't know which fields are arrays so you can optionally specify a list of dotted paths which should be treated as an array. mongoQueryĪn object containing MongoDB query operators. This is the name of your jsonb column in your postgres table which holds all the data. Var mToPsql = require ( 'mongo-query-to-postgres-jsonb' ) mToPsql(sqlField, mongoQuery, ) sqlField
