the name of the model, alias table
Static
_schemaReturns an array of the column names specified in
Deletes every data from the table, use this with caution;
Inserts new record to the table,
an object of new record to be created.
Inserts multiple new records to the table,
an array of one or more records to be created.
Get details about your model, alias for describe_table
Returns all data from the table.
an array of columns or an object with options.
Deletes multiple data from the table based on the specified values.
Return data from table using matching conditions.
Returns one or more data from the table matching the specified primaryKey
values.
Deletes data from the table, matching the specified ids.
an array of values of your primaryKey
.
Returns data from a table with matching values.
Returns a single data from the table matching the specified value.
Optional
getAttributes: string[]Load data to a table from a CSV string.
Load data to a table from a local CSV file.
Load data to a table from an external CSV file.
Load data to a table from amazon S3.
Execute custom SQL queries.
Updates the table with the specified records.
an array of one or more records to be updated, Note: the records must include their primary key (e.g id).
Update nested values by specifying a path.
// using the following sample data
{id:1,username:'luckyv', friends:[{age:20,name:'mike'},{age:24,name:'jane'}]
}
// example 1
// this will update the name of first item in the array from 'mike' to 'debbie'
myUsersModel.updateNested({
id:1,path:'friends.0.name',value:'debbie'})
// example 2
myUsersModel.updateNested({
id:1,path:['friends,'0','age'],value:(data)=> {
// update the value
data.friends[1].age += 10;
// the return it
return data.friends[1].age
})
// example 3
myUsersModel.updateNested({
id:1,path:'friends',value:(data)=> {
// add a new item
data.friends.push({name:'bobby',age:32})
return data.friends
}
})
A model represents a table, each model is connected with a table specified as
modelName