作者
digoal
日期
2020-03-24
标签
PostgreSQL , mongodb
背景
https://github.com/postgrespro/monq
MonQ
postgreSQL extension for MongoDB query support
Introduction
MonQ – is a postgreSQL extension which allow use mongoDB query language to query jsonb data type, introduced in PostgreSQL release 9.4.
The main task of this extension is to provide apportunity to make queries on mongodb query language, translate their in to jsquery query language and return result of them.
MonQ is released as mquery data type and <=> match operator for jsonb.
```
Usage
MonQ extension contains:
mquery - datatype which represents MongoDB query in tree structure;
<=> - maching operator which take like arguments jsonb document and mongoDB query. This operator have 2 variants of representation: jsonb <=> mquery and mquery <=> jsonb.
Example of query:
select '{ "a" : [ "ssl","security", "pattern"] }'::jsonb <=>
'{ a: { $all: [ "ssl","security"] } }'::mquery;
This mongoDB query:
{ a: { $all: [ "ssl","security"] } }
transformed to this JsQuery query:
a @> [ "ssl","security"]
and passed like arguments to JsQuery execution functions with jsonb document. Execution function return true or falsedependently of result.
?column?
t
(1 row)
You cah use key a without quotes, but if it complicated key "a.b.c.qwerty.d" you need to use them.
```
PostgreSQL 许愿链接
您的愿望将传达给PG kernel hacker、数据库厂商等, 帮助提高数据库产品质量和功能, 说不定下一个PG版本就有您提出的功能点. 针对非常好的提议,奖励限量版PG文化衫、纪念品、贴纸、PG热门书籍等,奖品丰富,快来许愿。开不开森.