Skip to content

AshwinNBhanushali/SQLite3-WinRT

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

182 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SQLite3-WinRT

Async SQLite for (JavaScript) Windows Store apps.

Status

Please note that SQLite3-WinRT is currently in beta stage. The API covers the better part of every day use cases, but might still be missing some functionality or even change slightly in the future. However, it is already being used by certified apps published in the Windows Store. Feedback and contributions are highly appreciated, feel free to open issues or pull requests on GitHub.

Setup

SQLite3-WinRT consists of two parts, a WinRT component named SQLite3Component and a JavaScript namespace called SQLite3JS that builds upon the SQLite3Component.

Therefore, in order to use SQLite3JS in a JavaScript app, the SQLite3Component project SQLite3Component\SQLite3Component.vcxproj must be added to the app's solution using FILE > Add > Existing Project.... A reference to SQLite3Component must be added to the app's project using PROJECT > Add Reference.... Now, the SQLite3JS source SQLite3JS\js\SQLite3.js can be used in the app's project.

Note for users of Visual Studio 2012 Express: To compile the WinRT component successfully, please install the Windows SDK.

Usage

The SQLite3JS namespace provides an async JavaScript API for SQLite. It is built around the Database object that can be obtained using SQLite3JS.openAsync(). The API was inspired by node-sqlite3.

Example

var dbPath = Windows.Storage.ApplicationData.current.localFolder.path + '\\db.sqlite';
SQLite3JS.openAsync(dbPath)
  .then(function (db) {
    return db.runAsync('CREATE TABLE Item (name TEXT, price REAL, id INT PRIMARY KEY)');
  })
  .then(function (db) {
    return db.runAsync('INSERT INTO Item (name, price, id) VALUES (?, ?, ?)', ['Mango', 4.6, 123]);
  })
  .then(function (db) {
    return db.eachAsync('SELECT * FROM Item', function (row) {
      console.log('Get a ' + row.name + ' for $' + row.price);
    });
  })
  .then(function (db) {
    db.close();
  });

License

Copyright (c) 2012 doo GmbH

Licensed under the MIT License, see LICENSE file.

About

SQLite3 WinRT Component

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors