lowdb-titanium-adapter

1.0.1 • Public • Published

lowdb-titanium-adapter

Build Status npm

Titanium SDK adapter for the LowDB embedded database.

You can use this library to persist LowDB databases inside Titanium applications using the Titanium API. Everything else operates normally as LowDB would do in any other environment, so see their repository for further information.

Usage

This module is on npm, so feel free to grab from there (as well as lowdb):

$ npm i lowdb lowdb-titanium-adapter

You can then configure it inside your application pretty easily, as the API is still synchronous for the time being:

// Load our modules
const low = require('lowdb');
const TitaniumAdapter = require('lowdb-titanium-adapter');

// Initialize the database to write to my-database.json
const adapter = new TitaniumAdapter('my-database.json', {
  // Describe the default schema.
  //
  // This will be used as the "base" state for your database. See the
  // LowDB documentation for more information. You can also handle this
  // by calling the `defaults()` method on your database instance.
  defaultValue: {

  },
});

// Create the database instance.
//
// This requires an async context, so you need to use a function
// as shown below until we can use `await` in the main `app.js`.
let db; (async () => db = await low(adapter));

There is also a more complete example app available - just remember to run npm install before you try to run it. For any further usage, check out the LowDB docs as the API is exactly the same.

Dependents (0)

Package Sidebar

Install

npm i lowdb-titanium-adapter

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

5.48 kB

Total Files

7

Last publish

Collaborators

  • whitfin