New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

indexddb-rest

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

indexddb-rest

Base para persistir datos en el exporador

latest
Source
npmnpm
Version
1.1.3
Version published
Maintainers
1
Created
Source

IndexedDB_REST

Use indexeddb like api rest.

##Install

npm -i indexddb-rest

##Setup

We use this library like indexeddb, so we need make a litle setup.

note: All created tables have id automatically.

let ref = require('indexddb-rest');

const IndexedDBREST = ref.IndexedDBREST;

function onError(err) {

}

let db = new IndexedDBREST( 'myDB', 1, [{name: 'table1'}, {name: 'table2'}], onError);

##Create data

When you add a value to a table, the id is automatically incremented. Return a copy of the item created.

db.post('table1',{some: 'nanananana'}).then(response => {
    console.log('save something', response);
}).catch(error => {
    console.log('bad something happened');
});

If you dont need generate a row with autoid, use this.

db.post('table1',{some: 'nanananana'}, false).then(response => {
    console.log('save something', response);
}).catch(error => {
    console.log('bad something happened');
});

##Read data

We have two methods: get and list.

Get return one element of the table.

List return all elememts of the table.

Return a copy of the item solicited.

db.get('table1', 142563652).then(response => {
    console.log('the item', response);
}).catch(error => {
    console.log('not exist the item');
});

Return a copy of the list.

db.list('table1').then(response => {
    console.log('the list', response);
}).catch(error => {
    console.log('');
});

##Update data Note: if the id no exist, the item is save automatically. Return a copy of the item updated.

db.put('table1',{id: 142563652, some: 'nanananana'}).then(response => {
    console.log('upddate something', response);
});

##Delete data

All items have a id, so when we delete a item use the id of item for delete it.

Return true or false.

db.delete('table1', 142563652).then(response => {
    console.log('delete the item', response);
});

Keywords

js

FAQs

Package last updated on 13 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts