Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dvshu/phql
Convert a string of a specific format to the data filter parameter form of MongoDB.
https://github.com/dvshu/phql
filter mongodb phql
Last synced: about 2 months ago
JSON representation
Convert a string of a specific format to the data filter parameter form of MongoDB.
- Host: GitHub
- URL: https://github.com/dvshu/phql
- Owner: DvShu
- License: mit
- Created: 2019-03-28T09:04:57.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-03-28T09:46:39.000Z (almost 6 years ago)
- Last Synced: 2024-11-20T05:48:25.674Z (about 2 months ago)
- Topics: filter, mongodb, phql
- Language: JavaScript
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# phql
Convert a string of a specific format to the data filter parameter form of MongoDB.
## English
### Installation
```NodeJs
yarn add phql
```
### Usage
Usually used for client dynamic acquisition of required fields in web applications.
```NodeJs
let parseQl = require('phql');
let filterObj = parseQl('{name,age,sex,info{weight,height}}')
```
### Specific Format String
```
{name,age,sex,info{weight,height}}
```
### Parsed Result
`MongoDB` [projections](http://mongodb.github.io/node-mongodb-native/3.2/tutorials/projections/ "projections")
```javascript
{
name: 1,
age: 1,
sex: 1,
info: {
weight: 1,
height: 1
}
}
```
## 简体中文
通常用于在使用 `MongoDB` 的 `WEB` 应用程序中,客户端动态获取自己所需要的字段;这个时候客户端可以传递特定格式的字符串,然后服务端解析该字符串为 `MongoDB Projections` 的形式传递给 `MongoDb` 。
# License
[MIT](https://github.com/DvShu/phql/blob/master/LICENSE "MIT")