Model interface
Overview
The SugoiJS ModelAbstract
and ConnectableModel
contains predefined methods for CRUD which use as interface for the custom CRUD logic
Interface
Find
(static method) findAll(query: any = {}, options?: QueryOptions) - query all records
(static method) findOne(query: any = {}, options:QueryOptions ={limit:1}) - query one record
(static method) findById(id: string | number, options:QueryOptions ={limit:1}) - query by id
(static method) find(query: any = {}, options?: QueryOptions) - customize query
Remove
(static method) removeAll(query: any = {}, options?: QueryOptions) - remove all records
(static method) removeOne(query: any = {}, options:QueryOptions ={limit:1}) - remove one record
(static method) removeById(id: string | number, options:QueryOptions ={limit:1}) - remove by id
(instance method) remove(query: any = {}, options?: QueryOptions) - remove the record itself
Save (create)
(instance method) save(options?: QueryOptions) - Save instance to DB\Microservice
Update
(static method) updateById(id: string | number, options:QueryOptions ={limit:1}) - update by id
(static method) updateAll(query:any, data:any, options:QueryOptions) - update all records which fit the query term
(instance method) update(options?: QueryOptions) - Update instance on DB\Microservice
Last updated