sydb
v2.0.1
Published
A simple local database using the Node.js file system module.
Downloads
3
Maintainers
Readme
const Sydb = require('sydb')
const db = new Sydb(options)
| Parameter | Type | Optional | Default | Descrirption |
|-------------------|-----------|----------|---------------|-------------------------------------------------------------------------------------------------------------------|
| options.path | string
| false
| ./sydb.json
| Database File Path |
| options.split | string
| true
| /
| Separator for dividing to reference properties |
| options.autoSave | boolean
| true
| false
| Automatically save when you hear a change |
| options.spaceJson | number
| true
| 4
| Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. |
Json File
{
"users": {
"002": {
"name": "Pinho",
"username": "jvopinho",
"skills": [
"JavaScript",
"TypeScript",
"NodeJS",
"ReactJS",
"NextJS"
]
}
}
}
const Sydb = require('sydb')
const db = Sydb(__dirname + '/sydb.json')
db.ref('reference')
// Example
db.ref('users/001')
db.ref(reference).val()
db.ref('users/002').val() // -> { name: 'Pinho', username: 'jvopinho', skills: [...] }
db.ref('users/').val({ type: 'map' }) // -> Map(1) { '002': [Object] }
db.ref(reference).set(value)
db.ref('users/002').set({
name: 'John Pinho',
}) // -> { users: { '002': { name: 'John Pinho' } } }
db.ref(reference).update(value)
db.ref('users/002').update({
username: 'JPinho'
}) // -> { users: { '002': { name: 'Pinho', username: 'JPinho', skills: [...] } } }
db.ref('reference').delete()
db.ref('users/002').delete() // -> { users: {} }