Changes the table name of the database/model.
db.setTable('products');
// or
Products.setTable('products').find(1);
- name
string
— name of the custom method (called withdb[name]()
) - fn
function
— a function that returns a query (either a string, query chain, or queue object) - [map]
function
— an optional function to map the results to (called per iteration)
Model.addQueryMethod("nameFromJob", function(job) {
return Model.select("name").where({ job: job });
}, function(row) {
return row.name;
});