Number of entities in the datastore class
ds.MyDataclass.length
returns an object of type EntityCollection containing all the entities in the datastore class
ds.MyDataclass.all()
returns the arithmetic average of all the non-null values of attribute for the datastore class or entity collection
Compute performs, in a single call, all the statistical calculations on the attribute or list of attributes passed as the parameter for the datastore class or entity collection
DatastoreClassAttribute,String Attribute(s) for which you want to perform statistical calculations
Boolean Compute distinct calculations - false
by default
Object containing the following calculations :
- average Arithmetic average
- averageDistinct Average taking only distinct values into account
- count Number of values
- countDistinct Number of distinct values
- max Maximum value
- min Minimum value
- sum Sum
- sumDistinct Sum taking only distinct values into account
Compute performs, in a single call, all the statistical calculations on the attribute or list of attributes passed as the parameter for the datastore class or entity collection
DatastoreClassAttribute,String Attribute(s) for which you want to perform statistical calculations
DatastoreClassAttribute,String Attribute(s) on which you want to have subtotal breaks
Object containing all the calculations performed and subtotals
var stats = ds.Sales.all().compute("benefit, revenues", "country, month");
// compute `benefit`and `revenues` values of a Sales class grouped by country and month
// for more convenience the returned object can be converted into an array
stats.toArray();
The Count() method returns the number of entities contained in the entity collection or datastore class
DatastoreClassAttribute,String Attribute whose value must not be null
Boolean Default false
Use only entities that have different values
Number of entities in the collection or Dataclass
creates a new blank object of type Entity based on the datastore class.
creates a new blank object of type EntityCollection attached to the datastore class
Boulean - True
to create a SortedCollection (false
by Default)
For more information about sorted/unsorted collection, visit this page
The distinctValues( ) method creates an array and returns in it all the distinct values stored in attribute for the entity collection or datastore class
DatastoreClassAttribute Attribute for which you want to get the list of distinct values
Array containing the list of distinct values
//In our example, we want to return the total number of different jobs in the same company:
var employer = ds.Company.find( "name == :1", "WAKANDA" ) ; // find the company by its name
var allEmp = ds.Employee.query("comp == :1", employer); // create an entity collection containing all the employees in a company
// 'comp' is a relation attribute in Employee
var jobNb = allEmp.distinctValues("jobName").length; //`jobName` is a DatastoreClassAttribute of Employee
// In a "keywords" object attribute of an Article datastore class, you store the page numbers for each keyword in a "pages" array.
// You want to know all pages that contain at least one keyword
var arr = ds.Article.all().distinctValues("keywords.pages[]");
exports all the entities stored in the object for which it is called in JSON format It can be called for a :
- datastore
- DatastoreClass
- EntityCollection
Folder Folder where you want to export the collection.
Number Maximum number of files per Folder
Number Size limit vamue of export files (in KB)
Number Size limit (in bytes) velow which the contents of a BLOB or Picture attribute are embedded into the main file
exports all the entities stored the object for which it is called in SQL format It can be called for a :
- datastore
- DatastoreClass
- EntityCollection
Folder Folder where you want to export the collection.
Number Maximum number of files per Folder
Number Size limit vamue of export files (in KB)
Number Size limit (in bytes) velow which the contents of a BLOB or Picture attribute are embedded into the main file
Search operation in a the DatastoreClass or EntityCollection that returns the first entity
found in an object of type Entity
The find( ) method is equivalent to executing a query( ) followed by retrieving the first entity:
For more details and exemples check the Query method section
ds.Employee.find( "name == DOE");
ds.Employee.find( 'name ==:1', "DOE");
Value(s) to compare when using placeholders
The first found entity in the collection
Returns the entity in the first position of the entity collection or datastore class
ds.Employee.query('ID > 2').first() //exemple1
ds.Company.first() //exemple2
Executes the callbackFn function on each entity in the entity collection(or Dataclass) in ascending order
Function Handler function to invoke for each entity in the collection
The callbackFn function accepts two parameters: function (
thisArg
, iterator
)
thisArg
, represents the entity currently being processed. When it is executed, the function receives in this parameter the entity on which it iterates (the parameter is used like the keyword this
). You can then perform any type of operation on the values of the entity.iterator
, is the iterator. When it is executed, the function receives in this parameter the position of the element currently being processed in the entity collection. You can use it, for example, to display a counter.
generates entities in the datastore class where it is applied and returns the resulting entity collection
New entity collection
getCollectionPageLength
returns the default page size of a dataclass.
Dataclass page size.
myRemoteDatastore.Employees.getCollectionPageLength();
returns the percentage of logical fragmentation for the entities of the datastore class
Tip : Beyond a rate of 20% (0.2), it may be useful to [compact the datastore data] (http://doc.wakanda.org/Datastore/Datastore-Maintenance-Methods/compactDataStore.301-595628.en.html)
Works only with Wakanda Built-in DB. (i.e. do not concern MySQL / ODBC / Custom catalog)
returns the name of the datastore class to which it is applied in a string
var nameEM = ds.Book.getName();
returns the current scope property value of the datastore class
Two values can be returned for a datastore class: (default value public
)
- "public": a public datastore class can be accessed from anywhere (including on the client side)
You can get more information about the Datastore Class Properties here
imports all the entities stored in JSON format from the file(s) located in the importFolder folder
The importFromJSON( ) method can be called for a:
- Datastore: entities from all the datastore classes are imported,
- DatastoreClass: entities from the datastore class are imported.
This method only work with the Wakanda Built-in database (MYSQL and other Connectors are not concerned)
Returns the maximum value among all the values of attribute in the entity collection or datastore class
DatastoreClassAttribute Attribute for which you want to get the highest value.
Number Highest value of attribute
//We want to find the highest salary among all the female employees:
var fColl = ds.Employee.query("gender == :1","female");
var maxFSalary = fColl.max("salary");
var value = ds.MyClass.all().max("objectAtt.prop") //Highest of all prop attribute values
returns the lowest (or minimum) value among all the values of attribute in the entity collection or datastore class
DatastoreClassAttribute Attribute for which you want to get the lowest value.
Number Lowest value of attribute
//We want to find the lowest salary among all the female employees:
var fColl = ds.Employee.query("gender == :1","female");
var maxFSalary = fColl.min("salary");
var value = ds.MyClass.all().min("objectAtt.prop") //Lowest of all prop attribute values
The orderBy method sorts the entities in the entity collection or datastore class and returns a new sorted entity collection
DatastoreClassAttribute Attribute(s) to be sorted and (if String) order by direction(s)
string asc
(by default
) for ascending sort / desc
for descending.
searches all the entities in the datastore class or entity collection using the search criteria specified in queryString and returns a new collection containing the entities found
The Query method description is fully described [here (entity collection part)] (entitycollection.html#query)
Permanently removes entities from the datastore
// Applied to a Dataclass
ds.Dataclass1.remove();
// Applied to a collection
ds.Dataclass1.query('ID > 3 & ID < 5').remove();
// Applied to an entity
ds.Dataclass1.first().remove();
// Applied at the Model level (Entity method on the Customer dataclass)
model.Customer.entityMethods.remove = function() {
this.remove();
};
(re)sets the start value for the autosequence number of the datastore class
New start value for entity counter This method (re)sets the start value for the autosequence number of the datastore class.
note : the ID is based on this internal counter. An autosequence number can be set for any attribute on [Model Designer] (http://doc.wakanda.org/Datastore-Model-Designer/Datastore-Model-Designer.100-1051416.en.html)
setCollectionPageLength
sets the default dataclass page size returned by each query. This setting is only applied to the current dataclass.
Number of entities return by each query
myRemoteDatastore.Employees.setCollectionPageLength(80);
returns the sum (i.e., total of all the values) of attribute for the datastore class or entity collection
false
by Default Use only entities that have different values
var highSalaries = ds.Employees.query("salary > 30000").sum("salary" , true);
var propSum = ds.MyClass.all().sum("objectAtt.prop") //sum of all prop attribute values
The toArray() method creates and returns a JavaScript array where each element is an object containing a set of properties and values corresponding to the attribute names and values for a datastore class or an entity collection
DatastoreClassAttribute List of attributes to return as array or "" to return all attributes
string list of attributes used for the sort
boolean Include the entity key and stamp false
by default
number Position of starting entity to return
number Number of entities to return
Array containing attributes and values of datastore class or entity collection
You can of course navigate through dataclasses via relation attributes.
In this scenario you can even limit the number of related entities fetched by passing RelatedAttribure: N
(where N represents the number of sub elements)
// - Retrieve the first five students.
// - Limit the number of courses per student to five.
// - Sort arrays by the student's first name and sort course sub-arrays by subject name. Both in ascending order.
// - skip the 1st result
var sel = ds.Student.all();
var myArray = sel.toArray("fullName, Course:5, Course.matter, Course.teacher.fullName", "firstName, Course.matter", 1, 5);
`
returns a string representation of the entity or entity collection
ds.Dataclass1.query('ID > 3').toString() // applied to a collection
ds.Dataclass1.first().toString() // applied to an entity
Collection of available attributes
Object containing all the attributes of the DatastoreClass
ds.MyDataclass.attributes