Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ghondar/lowdb-recursive
Flat JSON file database recursive
https://github.com/ghondar/lowdb-recursive
Last synced: about 2 months ago
JSON representation
Flat JSON file database recursive
- Host: GitHub
- URL: https://github.com/ghondar/lowdb-recursive
- Owner: ghondar
- License: mit
- Created: 2015-07-06T20:44:11.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2022-02-12T15:25:08.000Z (almost 3 years ago)
- Last Synced: 2024-11-05T16:59:15.569Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 134 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 80
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# lowdb-recursive
[![Build Status](https://travis-ci.org/ghondar/lowdb-recursive.svg?branch=master)](https://travis-ci.org/ghondar/lowdb-recursive)
[![Dependencies](https://david-dm.org/Ghondar/lowdb-recursive.svg?style=flat-square)](https://david-dm.org/Ghondar/lowdb-recursive)
[![DevDependencies](https://david-dm.org/Ghondar/lowdb-recursive/dev-status.svg?style=flat-square)](https://david-dm.org/Ghondar/lowdb-recursive#info=devDependencies&view=list)
[![Donate to help support Ghondar development](https://img.shields.io/gratipay/ghondar.svg?style=flat)](https://www.gittip.com/ghondar/)> Quick dot-notation seeker
if you know for the first time lowdb, please go [here](https://github.com/typicode/lowdb)
## Add Documents
```javascript
var low = require('lowdb-recursive')var db = low('db.json')
var collection = [
{
"nombre": "Villareal",
"numero": 1,
"carreras": [
{
"nombre": "Fisico",
"rating": 4.3,
"cursos": [
{
"nombre": "cuantica",
"id": 1
},
{
"nombre": "algebra",
"id": 2
}
]
},
{
"nombre": "Matematica",
"rating": 4,
"cursos": [
{
"nombre": "algebra",
"id": 2
},
{
"nombre": "Aritmetica",
"id": 3
}
]
}
]
},
{
"nombre": "San Marcos",
"numero": 2,
"carreras": [
{
"nombre": "Medicina",
"rating": 9.6,
"cursos": [
{
"nombre": "Quimica",
"id": 4
},
{
"nombre": "Biologia",
"id": 5
}
]
},
{
"nombre": "Metalurgia",
"rating": 5,
"cursos": [
{
"nombre": "quimica",
"id": 4
},
{
"nombre": "Fisica",
"id": 5
}
]
}
]
}
]collection.forEach(function(document){
db.get('universidades').push(document).write();
});```
## Find```javascript
/*
[ { nombre: 'Villareal',
numero: 1,
carreras: [ [Object], [Object] ] } ]
*/db.get('universidades').whereAll({ 'carreras.cursos.nombre': 'cuantica'})
//or
/*
[ { nombre: 'cuantica', id: 1 } ]
*/db.get('universidades').findAll({ 'carreras.cursos.nombre': 'cuantica'})
```
## Update and get values
```javascriptdb.get('universidades')
.chain()
.updateAll({'carreras.cursos.nombre': 'cuantica'}, {'nombre': 'mecanica'})
.write()
.value()//or
db.get('universidades')
.chain()
.findAll('carreras.cursos.nombre': 'cuantica')
.updateAll({'nombre': 'mecanica'})
.write()
.value()```
## Push value
```javascriptdb.get('universidades')
.chain()
.pushAll({'carreras.cursos.nombre': 'cuantica'}, {'nombre': 'javascript', 'id': 100})
.write()
.value()//or
db.get('universidades')
.chain()
.findAll({"carreras.rating": 4.3})
.pushAll({"cursos": {'nombre': 'javascript', 'id': 100})
.write()
.value()```
## Remove value
```javascriptdb.get('universidades')
.chain()
.removeAll({'carreras.cursos.nombre': 'cuantica'})
.write()
.value()```