1.3.0 • Published 5 years ago

cocodb v1.3.0

Weekly downloads
-
License
ISC
Repository
github
Last release
5 years ago

CocoDB

Getting started

1. Create a new CocoDB instance

const { CocoDB, LocalStorage } = require('cocodb')
const db = new CocoDB({
    storage: LocalStorage, // optional
    storageName: '__localdb' // optional
})

// u can add a Storage
db.setStorage({
    storage: LocalStorage, // optional
    storageName: '__localdb' // optional
})

2. You can use the following methods

2.1. Add elements

await db.add({
    name: 'Wilson',
    age: 12
})

// or add multiple
await db.addMany([
    {
        name: 'Wilson',
        age: 44
    },
    {
        name: 'Zon',
        age: 25
    }
])

2.2. Find elements

// using id
await db.findById('123')

// using a query object
// u can use a function, too. See: https://lodash.com/docs/#find
await db.find({
    name: 'Wilson'
})

2.3. Remove element

// using id
await db.remove('123')

2.4. Sort elements

await db.sortBy(['_id', 'name'])
// or
await db.sortBy(function(o) {
    return o.name
})

// see: https://lodash.com/docs/#sortBy

2.4. Save, restore and remove / Storage

// save the data to the storage
await db.save()
// restore data from the storage
await db.restore()
// remove data from the storage
await db.delete()
1.3.0

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago

0.2.6

6 years ago

0.2.5

6 years ago

0.2.3

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago