Skip to content

Instantly share code, notes, and snippets.

@k0sukey
Created January 8, 2012 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save k0sukey/1578667 to your computer and use it in GitHub Desktop.
Save k0sukey/1578667 to your computer and use it in GitHub Desktop.
/*
* Titanium mobile jsondb module sample
*/
Ti.API.info(Ti.Utils.sha1('testing'));
Ti.API.info(Ti.Filesystem.applicationDataDirectory);
var jsondb = require('com.irlgaming.jsondb');
var collection = jsondb.factory('objects', 'mysharedsecret');
collection.save({ hoge: 'fuga' });
collection.commit();
var result = collection.find({ hoge: { $eq: 'fuga' } });
result.forEach(function(value, key, array){
Ti.API.info(value.hoge);
});
collection.update({ hoge: { $eq: 'fuga' } }, { $set: { hoge: null } }, {}, false);
collection.commit();
collection.remove({ hoge: { $eq: null } });
collection.commit();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment