Development Kit Js

Data storage

APIs usage for interaction with data storage services

DirecStore - data query APIs

The data query APIs are chained methods which represent similarly to SQL query syntax Import data query module

        import {direcstore as ds} from 'direcbase'

      

Select query

        const result = await ds.select().from('table_name')
    .where('field_name', 'operator', 'value')
    .orderBy('field_name', 'ASC')
    .limit(10)
    .offset(5)
    .onChange((data) => {   
        // data changes handling logic here
    })                         

      

onChange method is applied for the purpose of listening to data changes in reatime

Insert query

        let entry = {
    // ... key-value pairs go here
}
const result = await ds.insert(entry).into('table_name')

      

Update query

        let recordKey = 'abc'
let updateData = {
    // ... key-value pairs go here
}
const result = await ds.update(recordKey).into('table_name').set(updateData)

      

Delete query

        let recordKey = 'abc'
const result = await ds.delete(recordKey).from('table_name')