Skip to content

Latest commit

 

History

History
50 lines (39 loc) · 1.75 KB

README.md

File metadata and controls

50 lines (39 loc) · 1.75 KB

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.