Skip to content

Triggering Create Event

To trigger an event, create and save a new instance of the Order object in the Backendless database. This can be done with any Backendless SDK (Android, iOS, JS, .NET), REST API or Backendless Console:

Consider the following class:
@interface Order : NSObject

@property(strong, nonatomic) NSString *objectId;
@property(strong, nonatomic) NSString *orderName;
@property(strong, nonatomic) NSNumber *orderAmount;

@end
The code below creates an instance of the class and saves in the Backendless Database:
Order *order = [Order new];
order.orderAmount = @1200;
order.orderName = @"Sample Order";

DataStoreFactory *dataStore = [Backendless.shared.data of:[Order class]];
[dataStore saveWithEntity:order responseHandler:^(Order *savedOrder) {
    NSLog(@"Order has been saved");
} errorHandler:^(Fault *fault) {
    NSLog(@"Error: %@", fault.message);
}];
Consider the following class:
@objcMembers class Order: NSObject {
    var objectId: String?
    var orderName: String?
    var orderAmount: NSNumber?
}
The code below creates an instance of the class and saves it in the Backendless Database:
let order = Order()
order.orderAmount = 1200
order.orderName = "Sample Order"

let dataStore = Backendless.shared.data.of(Order.self)
dataStore.save(entity: order, responseHandler: { savedOrder in
    print("Order has been saved")
}, errorHandler: { fault in
    print("Error: \(fault.message ?? "")")
})

NSDictionary *order = @{@"orderAmount": @1200, @"orderName": @"Sample Order"};

MapDrivenDataStore *dataStore = [Backendless.shared.data ofTable:@"Order"];
[dataStore saveWithEntity:order responseHandler:^(NSDictionary *savedOrder) {
    NSLog(@"Order has been saved");
} errorHandler:^(Fault *fault) {
    NSLog(@"Error: %@", fault.message);
}];
let order = ["orderAmount": 1200, "orderName": "Sample Order"] as [String : Any]

let dataStore = Backendless.shared.data.ofTable("Order")
dataStore.save(entity: order, responseHandler: { savedOrder in
    print("Order has been saved")
}, errorHandler: { fault in
    print("Error: \(fault.message ?? "")")
})