Remote Collections

A convenient way for managing collections with remote data

Getting started

Extending from Remote Collection

In order to implement each request per operation we need to extend from RemoteCollection

class ProductCollection extends TSCore.Data.RemoteCollection {
	
  public createOperation(operation) {
  
  }
  
  public updateOperation(operation) {
  
  }
  
  public destroyOperation(operation) {
  	
  }
}

Events

Remote Collections allow you to implement events that will be emitted when performing an create/update/destroy. They help define business rules for a certain collection. The following are the events supported by TSCore\Collections\RemoteCollection and their order of execution:

OperationNameCan stop operation
InsertingbeforeCreateYES
InsertingafterCreateNO
UpdatingbeforeUpdateYES
UpdatingafterUpdateNO
DestroybeforeDestroyYES
DestroyafterDestroyNO

Example event

var collection = new RemoteCollection('products');

collection.on('create', (evt) => {
  console.log(evt.params.item);
  // {}
});