Class Model
Defined in: | src/model.coffee |
Overview
Subclasses
CozyBackedModel, PouchdbBackedModel
Class Method Summary
- .all(params, callback) List all instance of a model assume the model has an "all" request
- .attachBinary(id, path, data, callback) attach a file to the object
- .attachFile(id, path, data, callback) attach a file to the object
- Object .cast(attributes, target = {}) cast a POJO using this model schema
- .create(data, callback) create a new instance of this model (POST)
- .defineRequest(name, request, callback) Define a map/reduce request for this model
- .destroy(id, callback) delete a model by its Id
- .exists(id, callback) check if a model with given Id exists.
- .find(id, callback) find a model by its Id (GET)
- .first(callback) Find the first item of this kind useful for singleton type Model
- LaterStream .getBinary(id, path, callback) get an attached file as a stream
- .getFile(id, path, callback) get an attached file as a stream
- .rawRequest(name, params, callback) Get results for defined request for this model pass the results as an array of object with id, key, value properties
- .removeBinary(id, path, callback) remove an attached file
- .removeFile(id, path, callback) remove an attached file
- .removeRequest(name, callback) remove a Request
- .request(name, params, callback) Get results for defined request for this model
- .requestDestroy(name, params, callback) Destroy results for defined request for this model
- .save(id, data, callback) save (create or update) a model whole state (PUT)
- .saveBinary(id, path, filePath, callback) [DEPRECATED] save an attached file to disk
- .saveFile(id, path, filePath, callback) [DEPRECATED] save an attached file to disk
- .search(query, callback) find docs by FTS
- .updateAttributes(id, data, callback) change some attributes of the model (PATCH)
Instance Method Summary
- ::attachBinary(path, data, callback) attach a file to the object Instance version of .attachBinary
- ::attachFile(path, data, callback) attach a file to the object Instance version of .attachFile
- Model ::constructor(attributes) constructor
- ::destroy(callback) desttroy Remove the model from the DB
- ::getAttributes() getAttributes
- ::getBinary(path, callback) get an attached file as a stream Instance version of .getBinary
- ::getFile(path, callback) get an attached file as a stream Instance version of .getFile
- ::index(fields, callback) index Index some fields on this model
- ::removeBinary(path, callback) remove an attached file Instance version of .removeBinary
- ::removeFile(path, callback) remove an attached file Instance version of .removeFile
- ::save(callback) [DEPRECATED] save update or create a model
- ::saveBinary(path, filePath, callback) [DEPRECATED] save an attached file to disk Instance version of .saveBinary
- ::saveFile(path, filePath, callback) [DEPRECATED] save an attached file to disk Instance version of .saveFile
- ::updateAttributes(attributes, callback) updateAttributes apply changes to model (dont change other fields)
Class Method Details
.all(params, callback) Source
.attachBinary(id, path, data, callback) Source
.attachFile(id, path, data, callback) Source
Object .cast(attributes, target = {}) Source
.create(data, callback) Source
.defineRequest(name, request, callback) Source
.destroy(id, callback) Source
.exists(id, callback) Source
.find(id, callback) Source
.first(callback) Source
LaterStream .getBinary(id, path, callback) Source
.getFile(id, path, callback) Source
.rawRequest(name, params, callback) Source
.removeBinary(id, path, callback) Source
.removeFile(id, path, callback) Source
.removeRequest(name, callback) Source
.request(name, params, callback) Source
.requestDestroy(name, params, callback) Source
.save(id, data, callback) Source
.saveBinary(id, path, filePath, callback) Source
.saveFile(id, path, filePath, callback) Source
.search(query, callback) Source
Constructor Details
Instance Method Details
::attachBinary(path, data, callback) Source
::attachFile(path, data, callback) Source
::destroy(callback) Source
::getAttributes() Source
::getBinary(path, callback) Source
::getFile(path, callback) Source
::index(fields, callback) Source
::removeBinary(path, callback) Source
::removeFile(path, callback) Source
::save(callback) Source
::saveBinary(path, filePath, callback) Source