- config models
- All temporary table will have
_tsuffix - Table will use
collection nameimplicitly elsetableNameprovided explicitly
- create a temporary table
- copy all data to temporary table
- drop original table
- create a new table
- copy data from temporary table
- drop temporary table
- what if schema name change?
- create table if not exists
- select all data from existing table
- copy data from existing table
- drop existing table
- create new table
- insert all copied data
- select existing data
- obtain current properties
- adding missing values to existing data
- remove unwanted data from existing data
$collection $model $schema $migrationprovider $seedprovider $databaseprovider pool(max,min)
- Establish data base connection based on environment
- SQLite for ionic
- WEBSQL for browsers
Apply latest migration and provide other utilities for:
- create table
- alter table
- add column
- remove column
- etc
- seed a table
Collection of models.
-
then
-
and / $and -
or / $or -
nor / $nor
-
eq / equals / $eq -
neq / $ne / $neq -
gt / $gt -
gte / $gte -
lt / $lt -
lte / $lte -
match / $match -
elementMatch / $elementMatch / $elemMatch -
in / $in -
nin / $nin -
mod / $mod -
regex / $regex -
not / $not
-
where -
sort -
skip -
limit -
gt -
gte -
lt -
lte -
eq/equals -
ne -
select -
distinct -
exists -
find -
findById -
findByIdAndRemove -
findByIdAndUpdate -
findOne -
findOneAnRemove -
findOneAndUpdate -
in -
nin -
or -
nor -
and -
map -
reduce
-
count -
sum -
average -
min -
max -
incr -
increment -
decr -
decrement
-
create
-
update -
upsert
-
remove -
delete
//User collection
angular
.module('ngPOS')
.factory('User',function(ngData){
return ngData.model('User',{
tableName:'users',
properties: {
firstName: {
type: String,
unique: true,
defaultsTo: defaultsTo
},
lastName: {
type: String
},
ssn: {
type: String,
primaryKey: true,
index: true
},
fullName:function(){}
},
withNoSSN: function(){}
});
}); save():Promiseremove():PromisetoJSON():ObjecttoObject():Object
angular
.module('ngPOS')
.controller(function(User){
$scope.user = User.new();
$scope.save = function(user){
user.save();
};
$scope.delete = function(user){
user.remove();
};
$scope.index = function(criteria, limit, offset){
User.find(criteria).limit(limit).offset(offset);
};
});