@liquicode/jsonstor-excel
v0.2.0
Published
A jsonstor adapter which stores documents in an Excel worksheet or CSV file.
Maintainers
Readme
jsonstor-excel
Home: http://jsonstor.liquicode.com
Version: 0.2.0
Documents are stored in an Excel spreadsheet file.
Overview
jsonstor defines one interface for working with a document store and implements it
for a variety of database products and file formats. The interface is the same whichever
adapter is underneath, so the storage a project uses becomes a configuration decision
rather than a structural one.
This package is one such adapter. Documents are stored in an Excel spreadsheet file.
It is packaged separately so that it stays optional. A project which does not store
documents this way never downloads xlsx.
See @liquicode/jsonstor for the interface,
and jsonstor.liquicode.com for the documentation.
Getting Started
npm install --save @liquicode/jsonstor-excelconst jsonstor = require( '@liquicode/jsonstor' )();
jsonstor.LoadPlugin( require( '@liquicode/jsonstor-excel' ) );
let storage = jsonstor.GetStorage( 'jsonstor-excel', {
Path: '...',
SheetName: '...',
AutoFlush: true,
PrimaryKey: "_id",
PrimaryKeyMutable: false,
HostIndex: false,
} );Settings
| Setting | Required | Default | Description |
|---|:---:|:---:|---|
| Path | Yes | - | Path to the Excel or CSV file storing the data. |
| SheetName | Yes | - | The name of the worksheet storing the data. |
| AutoFlush | No | true | Write the workbook on every insert, update, replace, and delete. |
| PrimaryKey | No | "_id" | The field which holds the identifier. Set it to the key field of an existing store. |
| PrimaryKeyMutable | No | false | Allow an update or replacement to change the identifier. When false, such an operation is refused. |
| HostIndex | No | false | Keep an index of identifiers, so a search by identifier does not read the whole collection. If something else writes the store, call RefreshIndex(). |
Peculiarities
- A document is a row. The first row of the worksheet holds the field names, and each document is a row below it. A field no earlier document had adds a column.
- The whole worksheet is kept in memory, as in
jsonstor-jsonfile, and the workbook is rewritten on each write, or onFlushStorage()withAutoFlush: false. - An object or array is stored as JSON text in its cell, and read back as the object or array.
- A field holding
nullreads back absent, because an empty cell cannot tell the two apart. - A
Pathending in.csvis written as CSV, which holds one worksheet. - Use it to share a collection with someone who works in Excel.
Storage Interface
Every adapter implements the same functions, and they are documented once: Storage Interface.
The operator list is not repeated here. A criteria, a projection, and an update are the engine's, and the list changes whenever the engine gains an operator - a copy in this file could only ever be out of date. See the Operator Reference.
Dependencies
xlsx: The SheetJS spreadsheet reader and writer.@liquicode/jsonstor: The storage interface.@liquicode/jsongin: The query engine.
