Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thornbill/polymod-sqlite
A library to support SQLite data sources in Polymod.
https://github.com/thornbill/polymod-sqlite
experimental polymod sqlite
Last synced: about 1 month ago
JSON representation
A library to support SQLite data sources in Polymod.
- Host: GitHub
- URL: https://github.com/thornbill/polymod-sqlite
- Owner: thornbill
- License: mit
- Created: 2017-10-22T05:06:42.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-29T04:24:16.000Z (over 6 years ago)
- Last Synced: 2024-04-24T04:11:59.905Z (7 months ago)
- Topics: experimental, polymod, sqlite
- Language: JavaScript
- Size: 131 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Polymod-SQLite
[![Build Status](https://travis-ci.org/thornbill/polymod-sqlite.svg?branch=master)](https://travis-ci.org/thornbill/polymod-sqlite)
A library to support SQLite data sources in [Polymod](https://github.com/dstreet/polymod).
## Install
```
npm install --save polymod polymod-sqlite
```## License
[MIT License](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](https://github.com/dstreet/polymod#sources).### SqliteSource
```js
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.```js
const { SqliteStore } = require('polymod-sqlite')const inMemoryStore = new SqliteStore()
const anonymousStore = new SqliteStore('')
const fileStore = new SqliteStore('foo.sqlite')
```The [node-sqlite](https://github.com/kriasoft/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.```js
const data = await store.db.all('SELECT * FROM [posts]')
```