Basics
Fetching records
GrandTotalQuery = grandtotal.newQuery("EntityName"); returns a GrandTotalQuery
GrandTotalQuery
GrandTotalQuery.records(); returns an array of the GrandTotalRecords
GrandTotalQuery.filter("Predicate"); returns a new GrandTotalQuery with the records matching the query
GrandTotalQuery.sort("Fieldname",(Boolean) ascending); returns a new GrandTotalQuery the sorted records
GrandTotalRecord = grandtotal.fetchRecord("EntityName","Predicate"); returns the first GrandTotalRecord that matches the Predicate
Sample Predicate:
- "name LIKE 'x' AND uid LIKE 'y'"
Creating Records
EditableGrandTotalRecord = grandtotal.insertRecord("EntityName"); returns an EditableGrandTotalRecord (mutable)
GrandTotalRecord
grandtotalrecord.formattedNumber(theNumber); returns a formatted String of the number
grandtotalrecord.propertyName(); returns the property of the record
grandtotalrecord.valueForKeyPath("keypath"); returns the value of the keypath
Sample KeyPaths:
- "dateSent.yearOfCommonEra"
- "dateSent.monthOfYear"
- "dateSent.dayOfMonth"
- "client.formattedAddress"
- "currency.name"
EditableGrandTotalRecord (inherits from GrandTotalRecord)
grandtotalrecord.setValue("propertyName",value); sets the value of the propery
Sample
var aClient = grandtotal.insertRecord("Client");
aClient.setValue("firstName","Joe");
aClient.setValue("lastName","Doe");
var aInvoice = grandtotal.insertRecord("Invoice");
aInvoice.setValue("parentDocument",aClient);
var aCost = grandtotal.insertRecord("Cost");
aCost.setValue("parent",aInvoice);
aCost.setValue("quantity",3);
aCost.setValue("unitPrice",99);
aCost.setValue("name","Three Items");
aCost.setValue("notes","with a lousy description");
Entities
%@