Operation API shorthand module.
- Version:
- 15.4.5
- Source:
Methods
(static) create(params) → {operation/js/api/Operation}
stable API
Creates an instance of 'create' operation.
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
params |
Object | Object literal with all possible parameters. Properties
|
- Version:
- 15.4.5
- Source:
Returns:
Example
var employee = Abcs.Entities().findById('my.custom.bop.Employee');
var operation = Abcs.Operations().create({
entity: employee,
record: {
firstName: 'Martin',
lastName: 'Janicek',
age: 28
}
});
operation.perform().then(function(operationResult) {
if (operationResult.isSuccess()) {
// Insert code you want to perform after record being created
}
}).catch(function(operationResult) {
if (operationResult.isFailure()) {
// Insert code you want to perform if record creation failed
}
});
(static) delete(params) → {operation/js/api/Operation}
stable API
Creates an instance of 'delete' operation.
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
params |
Object | Object literal with all possible parameters. Properties
|
- Version:
- 15.4.5
- Source:
Returns:
Example
var employee = Abcs.Entities().findById('my.custom.bop.Employee');
var operation = Abcs.Operations().delete({
entity: employee,
record: {
id: 1
}
});
operation.perform().then(function(operationResult) {
if (operationResult.isSuccess()) {
// Insert code you want to perform after record being deleted
}
}).catch(function(operationResult) {
if (operationResult.isFailure()) {
// Insert code you want to perform if record deletion failed
}
});
(static) read(params) → {operation/js/api/Operation}
stable API
Reads all records matching the given restrictions.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
Object | Object literal with all possible parameters. Properties
|
- Version:
- 15.4.5
- Source:
- See:
Returns:
Examples
require([
'operation/js/api/Conditions',
'operation/js/api/Operator'
], function(Conditions, Operator) {
var employee = Abcs.Entities().findById('my.custom.bop.Employee');
var firstName = employee.getProperty('firstName');
var condition = Conditions.SIMPLE(firstName, Operator.EQUALS, 'Martin');
var operation = Abcs.Operations().read({
entity: employee,
condition: condition
});
operation.perform().then(function(operationResult) {
if (operationResult.isSuccess()) {
// Insert code you want to perform after records are fetched
}
}).catch(function(operationResult) {
if (operationResult.isFailure()) {
// Insert code you want to perform if fetching of records failed
}
});
});
require([
'operation/js/api/Sorting'
], function(Sorting) {
var employee = Abcs.Entities().findById('my.custom.bop.Employee');
var firstName = employee.getProperty('firstName');
var operation = Abcs.Operations().read({
entity: employee,
sortBy: Sorting.ascending(firstName)
});
operation.perform().then(function(operationResult) {
// Insert code for Success/Failure handling
});
});
require([
'operation/js/api/Conditions',
'operation/js/api/Operator',
'operation/js/api/PaginationRequest'
], function(
Conditions,
Operator
PaginationRequest
) {
var employee = Abcs.Entities().findById('my.custom.bop.Employee');
var firstName = employee.getProperty('firstName');
var condition = Conditions.SIMPLE(firstName, Operator.EQUALS, 'Martin');
var pagination = PaginationRequest.createStandard({
offset: 15,
pageSize: 15
});
var operation = Abcs.Operations().read({
entity: employee,
condition: condition,
pagination: pagination
});
operation.perform().then(function(operationResult) {
// Insert code for Success/Failure handling
});
});
require([
'operation/js/api/ExpandableReference'
], function(
ExpandableReference
) {
// Creates an expandable reference for all relations between Employee and Department entities
var employee = Abcs.Entities().findById('my.custom.bop.Employee');
var department = Abcs.Entities().findById('my.custom.bop.Department');
var deptRef = ExpandableReference.create(department);
var operation = Abcs.Operations().read({
entity: employee,
expand: deptRef
});
operation.perform().then(function(operationResult) {
// Insert code for Success/Failure handling
// Result will contain main data with Employees and also each Employee will have Department record embedded
});
});
(static) update(params) → {operation/js/api/Operation}
stable API
Creates an instance of 'update' operation.
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
params |
Object | Object literal with all possible parameters. Properties
|
- Version:
- 15.4.5
- Source:
Returns:
Example
var employee = Abcs.Entities().findById('my.custom.bop.Employee');
var operation = Abcs.Operations().update({
entity: employee,
record: {
firstName: 'Martin',
lastName: 'Janicek',
age: 29
}
});
operation.perform().then(function(operationResult) {
if (operationResult.isSuccess()) {
// Insert code you want to perform after record being updated
}
}).catch(function(operationResult) {
if (operationResult.isFailure()) {
// Insert code you want to perform if record update failed
}
});
Type Definitions
Record
Object representing single record.
Type:
- Object.<String, String>
- Source: