Dataset
Dataset CRUD operations and realtime subscriptions
Constructor Summary
Public Constructor | ||
public |
constructor(name: string, client: Object) Create a dataset object with some initial values. |
Member Summary
Public Members | ||
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
Method Summary
Public Methods | ||
public |
Create a new record on the dataset |
|
public |
Delete a record from the dataset |
|
public |
Get a record from a dataset |
|
public |
Get information about the dataset, such as total records |
|
public |
List all records |
|
public |
Query a dataset with query parameters |
|
public |
Subscribe to realtime notfications The event name can be: 1. |
|
public |
unsubscribe(args: ...args) Unsubscribe from realtime notfications |
|
public |
Update a record on the dataset |
Public Constructors
Public Members
Public Methods
public create(data: Object): Promise<Object, Error> source
Create a new record on the dataset
Params:
Name | Type | Attribute | Description |
data | Object | Row data |
Example:
dataset.create({value: test}).then(function(res) {
console.log(res);
});
public delete(id: string): Promise<Object, Error> source
Delete a record from the dataset
Params:
Name | Type | Attribute | Description |
id | string | record id |
Example:
dataset.delete('s6svsrw452rwfs').then(function(res) {
console.log(res);
});
public get(id: string): Promise<Object, Error> source
Get a record from a dataset
Params:
Name | Type | Attribute | Description |
id | string | record id |
Example:
dataset.get('s6svsrw452rwfs').then(function(res) {
console.log(res);
});
public info(): Promise<Object, Error> source
Get information about the dataset, such as total records
Example:
dataset.info().then(function(res) {
console.log(res);
});
public list(): Promise<Array, Error> source
List all records
Example:
dataset.list().then(function(res) {
console.log(res);
});
public query(params: Object): Promise<Array, Error> source
Query a dataset with query parameters
Params:
Name | Type | Attribute | Description |
params | Object | query params |
Example:
dataset.query({limit: 1}).then(function(res) {
console.log(res);
});
public subscribe(args: ...args): Object source
Subscribe to realtime notfications The event name can be:
- None => Any kind of activity
- '*' => Any kind of activity
- 'created' => Only created rows
- 'updated' => Only updated rows
- 'deleted' => Only deleted rows
Params:
Name | Type | Attribute | Description |
args | ...args | Event name and callback function |
Emit:
jexia.dataset.subscription |
emit a new subscription event |
Example:
Subscribe to all events:
dataset.subscribe(function(data) {
console.log(data);
});
Subscribe to created events:
dataset.subscribe('created', function(data) {
console.log(data);
});
Subscribe to updated events:
dataset.subscribe('updated', function(data) {
console.log(data);
});
Subscribe to deleted events:
dataset.subscribe('deleted', function(data) {
console.log(data);
});
public unsubscribe(args: ...args) source
Unsubscribe from realtime notfications
Params:
Name | Type | Attribute | Description |
args | ...args | Event name and callback function |
Example:
dataset.unsubscribe(function(data) {
console.log(data);
});