Skip to content

konzz/tidesdk-orm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

tidesdk-orm

A JS ORM for TideSDK

To run the tests you need to create a TideSDK app and run them inside with a Jasmine HTML spec runner.

Basic usage:

Creating the model
var dbaccess = Ti.Database.open('test');
var usersSchema = {name: 'TEXT', surname: 'TEXT', age: 'INTEGER'}
var usersModel = timodel('users', usersSchema, dbaccess);
Creating the table (only creates if not exists)
usersModel.createTable();
Creating elements
//creates and returns the element
var john = usersModel.create({name: 'John', surname: 'sanders', age: 23});
john.id // 1;
Updating elements
john.age = 24;

john = usersModel.update(john);
john.age //24;
Finding elements
usersModel.create({name: 'John', surname: 'Smith', age: 23});
usersModel.create({name: 'Marta', surname: 'Smith', age: 24});
usersModel.create({name: 'Louis', surname: 'Peti', age: 26});

var users = usersModel.find({surname: 'Smith'});
users // [{id: 1, name: 'John', surname: 'Smith', age: 23}, {id: 2, name: 'Marta', surname: 'Smith', age: 24}];
/// If you dont pass a filter, it returns all the elements.
Deleting elements
usersModel.remove(2); // deletes the element with id = 2

About

A JS ORM for TideSDK

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published