@dankolz/indexeddb-data-service

1.0.1 • Public • Published

IndexedDBDataService

An implementation of the AbstractDataService interface for the browser's IndexedDB database. By default, it uses the same query syntax as MongoDB. Anything except a query based on the id will not be fast if there's a lot of documents, but it is functional.

Install

npm install @dankolz/indexeddb-data-service

Usage

In the browser

const DataService = require('@dankolz/indexeddb-data-service')

async function run(events) {
	let serv = new DataService({
		collections: {
			/* the name of the store (table/collection) name */
			default: 'people'
		}
		, databaseName: 'databasename'
	})
	
	await serv.init()
	
	await serv.save({firstName: 'Dan', lastName: 'Kolz'})
	let person = await serv.fetchOne({lastName: 'Kolz'})
	
	document.querySelector('#results').innerHTML = person.firstName
	
	await serv.remove(person.id)
}

run()

API

It's the api as used in @dankolz/abstract-data-service and the other implementation of the abstract data service @dankolz/mongodb-data-service

Readme

Keywords

Package Sidebar

Install

npm i @dankolz/indexeddb-data-service

Weekly Downloads

0

Version

1.0.1

License

ISC

Unpacked Size

12.6 kB

Total Files

4

Last publish

Collaborators

  • dankolz