-
Notifications
You must be signed in to change notification settings - Fork 5
Examples
Example:
[objectContext setDebugMode:LOObjectContextDebugModeSaveChanges | LOObjectContextDebugModeObserveValue]
var fetchSpecification = [LOFetchSpecification fetchSpecificationForEntityNamed:@"Person" qualifier:nil];
[objectContext requestObjectsWithFetchSpecification:fetchSpecification withCompletionHandler:function(objects, statusCode) {
if (statusCode === 200) {
// Do something with the objects
}
}];
An operator is extra information that is sent to the backend. It is used for example to tell the backend to do a lazy fetch (just send the primary keys) or count the number of objects (just send a number with the number of rows).
The default behavior that is used with the objc-backend is to add the operator after the method in the url. Normal url for a fetch is http://localhost/backend/fetch/Person. If a lazy
operator is added the url will look like http://localhost/backend/fetch/lazy/Person
var fetchSpecification = [LOFetchSpecification fetchSpecificationForEntityNamed:@"Person" qualifier:nil];
[fetchSpecification setOperator:@"lazy"];
[objectContext requestObjectsWithFetchSpecification:fetchSpecification withCompletionHandler:function(objects, statusCode) {
if (statusCode === 200) {
// Do something with the objects
}
}];
The default behavior that is used with the objc-backend is to use the method fetch
to fetch objects. Normal url for a fetch is http://localhost/backend/fetch/Person. If a special method is implemented in the backend to send objects to the client the url will look like http://localhost/backend/MyMethod/Person. This is how to tell the LOF to use an alternative method to fetch the objects
var fetchSpecification = [LOFetchSpecification fetchSpecificationForEntityNamed:@"Person" qualifier:nil];
[fetchSpecification setMethod:@"MyMethod"];
[objectContext requestObjectsWithFetchSpecification:fetchSpecification withCompletionHandler:function(objects, statusCode) {
if (statusCode === 200) {
// Do something with the objects
}
}];
var fetchSpecification = [LOFetchSpecification fetchSpecificationForEntityNamed:@"Person" qualifier:nil];
[fetchSpecification setRequestPreProcessBlock:function(request) {
[request setHTTPMethod:@"POST"];
[request setHTTPBody:[CPString JSONFromObject:{
sessionKey: theSessionKey,
itemKeys: itemKeys
}]];
}];
[objectContext requestObjectsWithFetchSpecification:fetchSpecification withCompletionHandler:function(objects, statusCode) {
if (statusCode === 200) {
// Do something with the objects
}
}];