waibu-db 1.2.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/bajo/hook/waibu-rest-api@after-init.js +10 -0
- package/index.js +2 -1
- package/package.json +4 -1
- package/waibuRestApi/route/@model/@id/get.js +5 -0
- package/waibuRestApi/route/@model/@id/remove.js +5 -0
- package/waibuRestApi/route/@model/@id/update.js +5 -0
- package/waibuRestApi/route/@model/create.js +5 -0
- package/waibuRestApi/route/@model/find.js +14 -0
package/README.md
CHANGED
|
@@ -18,6 +18,10 @@ $ npm install waibu-db
|
|
|
18
18
|
|
|
19
19
|
Now open your ```<bajo-data-dir>/config/.plugins``` and put ```waibu-db``` in it
|
|
20
20
|
|
|
21
|
+
## Configuration
|
|
22
|
+
|
|
23
|
+
- ```modelRestApi```: set to ```true``` to enable the auto creation of model's rest API. default: ```false```
|
|
24
|
+
|
|
21
25
|
## License
|
|
22
26
|
|
|
23
27
|
[MIT](LICENSE)
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "waibu-db",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "DB Helper",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
8
|
},
|
|
9
9
|
"type": "module",
|
|
10
|
+
"bajo": {
|
|
11
|
+
"type": "plugin"
|
|
12
|
+
},
|
|
10
13
|
"repository": {
|
|
11
14
|
"type": "git",
|
|
12
15
|
"url": "git+https://github.com/ardhi/waibu-db.git"
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
async function find (req, reply) {
|
|
2
|
+
const { isSet } = this.lib.aneka
|
|
3
|
+
const { parseObject } = this.app.bajo
|
|
4
|
+
let { fields, count } = this.getParams(req)
|
|
5
|
+
let rels = []
|
|
6
|
+
const headers = parseObject(req.headers, { parseValue: true })
|
|
7
|
+
if (isSet(headers['x-count'])) count = headers['x-count']
|
|
8
|
+
if (isSet(headers['x-rels'])) rels = headers['x-rels']
|
|
9
|
+
if (typeof rels === 'string' && !['*', 'all'].includes(rels)) rels = [rels]
|
|
10
|
+
const options = { fields, count, rels }
|
|
11
|
+
return await this.recordFind({ req, reply, options })
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default find
|