Package Exports
- borgoose
- borgoose/src/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (borgoose) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Borgoose
A Simple local JSON database

Install
npm i borgooseFunctions
Usage
new Borgoose(path, options)
const Borgoose = require("borgoose")
// default value of syncOnWrite is true
// I'm just writing you to see that such a setting exist :)
const bdb = new Borgoose("db.json", {syncOnWrite: true})Options
| Option | Type | Description | Default |
|---|---|---|---|
| syncOnWrite | Boolean | Automatically saves data to JSON file after each modification | true |
Examples
Insert (Create)
// Create single data
bdb.insertOne({name: 'Bora', age: 19})
// Create multiple data
bdb.insertMany([{name: 'Burak', age: 19}, {name: 'Baris', age: 26}])Find (Read)
// Find single data
bdb.findOne({age: 19})
// You can also use functions
bdb.findOne(o => o.age > 25)
// Find multiple data
bdb.findMany({age: 19})
// Get all data
bdb.findMany()Update
// Update single data
// It will set the age value of the data whose 'name' key is 'Bora' to 20.
bdb.updateOne({name: 'Bora'}, {age: 20})
// Update multiple data
// This will set the age values โโof all data less than 18 years old as 20.
bdb.updateMany(o => o.age < 18, {age: 20})Delete
// Delete single data
bdb.deleteOne({name: 'Bora'})
// You can also use functions
bdb.deleteOne(o => o.age < 20)
// Delete multiple data
bdb.deleteMany(o => o.age < 20)Write
// Replace all data with specified in parameter
bdb.write([{name: 'Bora'}])Shuffle
// Shuffle data
bdb.shuffle()Sync
// If syncOnWrite setting is false you have to use it to print data to json file.
bdb.sync()Developer Notes
- Use MongoDB.