polymod-sqlite
v1.1.0
Published
A sqlite data source for polymod.
Downloads
2
Readme
Polymod-SQLite
A library to support SQLite data sources in Polymod.
Install
npm install --save polymod polymod-sqlite
License
Documentation
This library implements the specifications for Sources in Polymod. Additional information about using Sources in Polymod can be found in the Polymod documentation.
SqliteSource
const { SqliteSource, SqliteStore } = require('polymod-sqlite')
const store = new SqliteStore()
const source = new SqliteSource(store, 'posts')
SqliteStore
By default the SqliteStore
constructor will create an anonymous in-memory SQLite database.
Additionally, an anonymous disk-based database can be created by passing an empty string to the constructor.
A filename can be specified to create a database that is persisted to a file.
const { SqliteStore } = require('polymod-sqlite')
const inMemoryStore = new SqliteStore()
const anonymousStore = new SqliteStore('')
const fileStore = new SqliteStore('foo.sqlite')
The node-sqlite instance used by the SqliteStore is exposed as the db
property on instances of the store.
This allows SQL statements to be executed directly on the database if needed.
const data = await store.db.all('SELECT * FROM [posts]')