Skip to content
Martin Diphoorn edited this page Jun 9, 2015 · 5 revisions

The NgDexie Quickstart

In this quick start we assume you are using bower to install JavaScript libraries. If you don't use bower then you have to manually copy the needed JavaScript files.

This component can only run in angular. If you don't have an angular project then please use the dexie.js library without this wrapper.

Install NgDexie

To start using NgDexie you will need to install it with bower:

bower install ng-dexie --save

Initializing

See the below example.

angular.module('yourApp', ['ngdexie', 'ngdexie.ui'])
    .config(function(ngDexieProvider){
        ngDexieProvider.setOptions({name: 'databaseName', debug: false});
        ngDexieProvider.setConfiguration(function (db) {
            db.version(1).stores({
                notes: "++id,title",
            });
            db.on('error', function (err) {
                // Catch all uncatched DB-related errors and exceptions
                console.error("db error err=" + err);
            });
    });

During the module configuration phase, we need to configure the database. There are 2 properties for this:

  • ngDexieProvider.setOptions for setting the database name and to set debug to true;
  • ngDexieProvider.setConfiguration handles a function to coonfigure your datbase see Dexe.Js for more information.

All db calls like db.version and db.on are straight on the Dexie object so see the dexiejs documentation.

Now you are able to use ngDexie in your controllers!

See the api for more information.

Clone this wiki locally