Spatial Data Create/Update API¶
Backendless SDK includes special classes which facilitate saving of spatial data values in the database. The same classes are used to represent spatial data when it is retrieved from the database. For more information about data retrieval, see the Spatial Data Retrieval API section.
POINT Values¶
Consider the following table schema in Backendless database. Notice the pickupLocation
and the dropoffLocation
columns. Both are of type POINT
:
The following code demonstrates how to create a new object with POINT
properties in the Order
table:
Order class:
@interface Order : NSObject
@property (strong, nonatomic) NSString *objectId;
@property (strong, nonatomic) NSString *orderName;
@property (strong, nonatomic) BLPoint *pickupLocation;
@property (strong, nonatomic) BLPoint *dropoffLocation;
@end
Order *order = [Order new];
order.orderName = @"Fun times";
order.pickupLocation = [[BLPoint alloc] initWithLongitude:37.578639 latitude:55.782309];
order.dropoffLocation = [[BLPoint alloc] initWithLongitude:37.618900 latitude:55.752917];
[[Backendless.shared.data of:[Order class]] saveWithEntity:order responseHandler:^(Order *savedOrder) {
NSString *objectId = savedOrder.objectId;
} errorHandler:^(Fault *fault) {
NSLog(@"Error: %@", fault.message);
}];
Order class:
@objcMembers class Order: NSObject {
var objectId: String?
var orderName: String?
var pickupLocation: BLPoint?
var dropoffLocation: BLPoint?
}
let order = Order()
order.orderName = "Fun times"
order.pickupLocation = BLPoint(longitude: 37.578639, latitude:55.782309)
order.dropoffLocation = BLPoint(longitude: 37.618900, latitude:55.752917)
Backendless.shared.data.of(Order.self).save(entity: order, responseHandler: { savedOrder in
guard let savedOrder = savedOrder as? Order else { return }
let objectId = savedOrder.objectId
}, errorHandler: { fault in
print("Error: \(fault.message ?? "")")
})
NSDictionary *order = @{@"orderName": @"Fun times",
@"pickupLocation": [[BLPoint alloc] initWithLongitude:37.578639 latitude:55.782309],
@"dropoffLocation": [[BLPoint alloc] initWithLongitude:37.618900 latitude:55.752917]};
[[Backendless.shared.data ofTable:@"Order"] saveWithEntity:order responseHandler:^(NSDictionary *savedOrder) {
NSString *objectId = savedOrder[@"objectId"];
} errorHandler:^(Fault *fault) {
NSLog(@"Error: %@", fault.message);
}];
let order = ["orderName": "Fun times",
"pickupLocation": BLPoint(longitude: 37.578639, latitude: 55.782309),
"dropoffLocation": BLPoint(longitude: 37.618900, latitude:55.752917)] as [String : Any]
Backendless.shared.data.ofTable("Order").save(entity: order, responseHandler: { savedOrder in
let objectId = savedOrder["objectId"] as? String
print(objectId)
}, errorHandler: { fault in
print("Error: \(fault.message ?? "")")
})
Codeless Reference
The example below creates a new object containing two GeoJSON (Point
) objects and saves it to the database called Order
:
where:
Argument | Description |
---|---|
table name |
Name of the data table where a new record must be saved. |
object |
An object to save in the database. Object properties must match the names of the table columns. The object must not have the objectId property. |
return result |
Optional parameter. When this box is checked, the operation returns the saved object with the objectId property. |
When you run the code(or Codeless logic), you will see the following in the database:
LINESTRING Values¶
Creating objects with LINESTRING
properties works similarly to the example shown above - your code needs to use corresponding class from the SDK. For example, the code below creates an object in the Travel
table with a LINESTRING
route:
Travel class:
@interface Travel : NSObject
@property (strong, nonatomic) NSString *objectId;
@property (strong, nonatomic) NSString *name;
@property (strong, nonatomic) BLLineString *route;
@end
NSString *route66LineString = @"LINESTRING (-87.52683788 41.85716752, -90.13875858 38.68967135, -95.93953983 36.2131248, -97.49959842 35.53656483, -101.8282117 35.26791494, -105.87118045 35.72083154, -106.61825076 35.14794417, -111.63900272 35.20182535, -118.24178592 34.07195769)";
Travel *travelObject = [Travel new];
travelObject.name = @"Route 66";
travelObject.route = [BLLineString fromWkt:route66LineString];
[[Backendless.shared.data of:[Travel class]] saveWithEntity:travelObject responseHandler:^(Travel *savedObject) {
NSString *objectId = savedObject.objectId;
} errorHandler:^(Fault *fault) {
NSLog(@"Error: %@", fault.message);
}];
Travel class:
@objcMembers class Travel: NSObject {
var objectId: String?
var name: String?
var route: BLLineString?
}
let route66LineString = "LINESTRING (-87.52683788 41.85716752," +
"-90.13875858 38.68967135, " +
" -95.93953983 36.2131248, " +
"-97.49959842 35.53656483, " +
"-101.8282117 35.26791494, " +
"-105.87118045 35.72083154, " +
"-106.61825076 35.14794417, " +
"-111.63900272 35.20182535, " +
"-118.24178592 34.07195769)"
if let path = BLLineString.fromWkt(route66LineString) {
let travelObject = Travel()
travelObject.name = "Route 66"
travelObject.route = path
Backendless.shared.data.of(Travel.self).save(entity: travelObject, responseHandler: { savedObject in
guard let savedObject = savedObject as? Travel else { return }
let objectId = savedObject.objectId
}, errorHandler: { fault in
print("Error: \(fault.message ?? "")")
})
}
NSString *route66LineString = @"LINESTRING (-87.52683788 41.85716752, -90.13875858 38.68967135, -95.93953983 36.2131248, -97.49959842 35.53656483, -101.8282117 35.26791494, -105.87118045 35.72083154, -106.61825076 35.14794417, -111.63900272 35.20182535, -118.24178592 34.07195769)";
BLLineString *path = [BLLineString fromWkt:route66LineString];
NSDictionary *travelObject = @{@"name": @"Route 66", @"route": path};
[[Backendless.shared.data ofTable:@"Travel"] saveWithEntity:travelObject responseHandler:^(NSDictionary *savedObject) {
NSString *objectId = savedObject[@"objectId"];
} errorHandler:^(Fault *fault) {
NSLog(@"Error: %@", fault.message);
}];
let route66LineString = "LINESTRING (-87.52683788 41.85716752," +
"-90.13875858 38.68967135, " +
" -95.93953983 36.2131248, " +
"-97.49959842 35.53656483, " +
"-101.8282117 35.26791494, " +
"-105.87118045 35.72083154, " +
"-106.61825076 35.14794417, " +
"-111.63900272 35.20182535, " +
"-118.24178592 34.07195769)"
if let path = BLLineString.fromWkt(route66LineString) {
let travelObject = ["name": "Route 66", "route": path] as [String : Any]
Backendless.shared.data.ofTable("Travel").save(entity: travelObject, responseHandler: { savedObject in
let objectId = savedObject["objectId"] as? String
}, errorHandler: { fault in
print("Error: \(fault.message ?? "")")
})
}
Notice the example above uses the LineString.fromWKT
method to convert a string representation of a geometry into an instance of the BLLineString
class. Alternatively, the code can use a constructor in the BLLineString
class which takes an collection of Point
objects. The example below and the one above produce exactly the same result using different approaches available in the SDK:
Travel class:
@interface Travel : NSObject
@property (strong, nonatomic) NSString *objectId;
@property (strong, nonatomic) NSString *name;
@property (strong, nonatomic) BLLineString *route;
@end
NSMutableArray *points = [NSMutableArray new];
[points addObject:[[BLPoint alloc] initWithLongitude:-87.52683788 latitude:41.85716752]];
[points addObject:[[BLPoint alloc] initWithLongitude:-90.13875858 latitude:38.68967135]];
[points addObject:[[BLPoint alloc] initWithLongitude:-95.93953983 latitude:36.2131248]];
[points addObject:[[BLPoint alloc] initWithLongitude:-97.49959842 latitude:35.53656483]];
[points addObject:[[BLPoint alloc] initWithLongitude:-101.8282117 latitude:35.26791494]];
[points addObject:[[BLPoint alloc] initWithLongitude:-105.87118045 latitude:35.72083154]];
[points addObject:[[BLPoint alloc] initWithLongitude:-106.61825076 latitude:35.14794417]];
[points addObject:[[BLPoint alloc] initWithLongitude:-111.63900272 latitude:35.20182535]];
[points addObject:[[BLPoint alloc] initWithLongitude:-118.24178592 latitude:34.07195769]];
Travel *travelObject = [Travel new];
travelObject.name = @"Route 66";
travelObject.route = [[[BLLineString alloc] initWithPoints:points];
[[Backendless.shared.data of:[Travel class]] saveWithEntity:travelObject responseHandler:^(Travel *savedObject) {
NSString *objectId = savedObject.objectId;
} errorHandler:^(Fault *fault) {
NSLog(@"Error: %@", fault.message);
}];
Travel class:
@objcMembers class Travel: NSObject {
var objectId: String?
var name: String?
var route: BLLineString?
}
var points = [BLPoint]()
points.append(BLPoint(longitude: -87.52683788, latitude: 41.85716752))
points.append(BLPoint(longitude: -90.13875858, latitude: 38.68967135))
points.append(BLPoint(longitude: -95.93953983, latitude: 36.2131248))
points.append(BLPoint(longitude: -97.49959842, latitude: 35.53656483))
points.append(BLPoint(longitude: -101.8282117, latitude: 35.26791494))
points.append(BLPoint(longitude: -105.87118045, latitude: 35.72083154))
points.append(BLPoint(longitude: -106.61825076, latitude: 35.14794417))
points.append(BLPoint(longitude: -111.63900272, latitude: 35.20182535))
points.append(BLPoint(longitude: -118.24178592, latitude: 34.07195769))
let travelObject = Travel()
travelObject.name = "Route 66"
travelObject.route = BLLineString(points: points)
Backendless.shared.data.of(Travel.self).save(entity: travelObject, responseHandler: { savedObject in
guard let savedObject = savedObject as? Travel else { return }
let objectId = savedObject.objectId
}, errorHandler: { fault in
print("Error: \(fault.message ?? "")")
})
NSMutableArray *points = [NSMutableArray new];
[points addObject:[[BLPoint alloc] initWithLongitude:-87.52683788 latitude:41.85716752]];
[points addObject:[[BLPoint alloc] initWithLongitude:-90.13875858 latitude:38.68967135]];
[points addObject:[[BLPoint alloc] initWithLongitude:-95.93953983 latitude:36.2131248]];
[points addObject:[[BLPoint alloc] initWithLongitude:-97.49959842 latitude:35.53656483]];
[points addObject:[[BLPoint alloc] initWithLongitude:-101.8282117 latitude:35.26791494]];
[points addObject:[[BLPoint alloc] initWithLongitude:-105.87118045 latitude:35.72083154]];
[points addObject:[[BLPoint alloc] initWithLongitude:-106.61825076 latitude:35.14794417]];
[points addObject:[[BLPoint alloc] initWithLongitude:-111.63900272 latitude:35.20182535]];
[points addObject:[[BLPoint alloc] initWithLongitude:-118.24178592 latitude:34.07195769]];
NSDictionary *travelObject = @{@"name": @"Route 66", @"route": [[BLLineString alloc] initWithPoints:points]};
[[Backendless.shared.data ofTable:@"Travel"] saveWithEntity:travelObject responseHandler:^(NSDictionary *savedObject) {
NSString *objectId = savedObject[@"objectId"];
} errorHandler:^(Fault *fault) {
NSLog(@"Error: %@", fault.message);
}];
var points = [BLPoint]()
points.append(BLPoint(longitude: -87.52683788, latitude: 41.85716752))
points.append(BLPoint(longitude: -90.13875858, latitude: 38.68967135))
points.append(BLPoint(longitude: -95.93953983, latitude: 36.2131248))
points.append(BLPoint(longitude: -97.49959842, latitude: 35.53656483))
points.append(BLPoint(longitude: -101.8282117, latitude: 35.26791494))
points.append(BLPoint(longitude: -105.87118045, latitude: 35.72083154))
points.append(BLPoint(longitude: -106.61825076, latitude: 35.14794417))
points.append(BLPoint(longitude: -111.63900272, latitude: 35.20182535))
points.append(BLPoint(longitude: -118.24178592, latitude: 34.07195769))
let travelObject = ["name": "Route 66", "route": BLLineString(points: points)] as [String : Any]
Backendless.shared.data.ofTable("Travel").save(entity: travelObject, responseHandler: { savedObject in
let objectId = savedObject["objectId"]
}, errorHandler: { fault in
print("Error: \(fault.message ?? "")")
})
Codeless Reference
The example below creates a new object containing one GeoJSON (LineString
) object and saves it to the database called Travel
:
where:
Argument | Description |
---|---|
table name |
Name of the data table where a new record must be saved. |
object |
An object to save in the database. Object properties must match the names of the table columns. The object must not have the objectId property. |
return result |
Optional parameter. When this box is checked, the operation returns the saved object with the objectId property. |
When you run the code(or Codeless Logic), you will see the following object in the database:
POLYGON Values¶
Creating objects with properties of type POLYGON
can be done by using the BLPolygon
class. Consider the following example, it is a data table called Building
with a schema which includes a column named shape
of type POLYGON
:
The code below demonstrates how to create a new object with a POLYGON property in the database:
Building class:
@interface Building : NSObject
@property (strong, nonatomic) NSString *objectId;
@property (strong, nonatomic) NSString *name;
@property (strong, nonatomic) BLPolygon *shape;
@end
NSString *pentagonPolygonString = @"POLYGON ((-77.05786152 38.87261877, -77.0546978 38.87296123, -77.05317431 38.87061405, -77.0555883 38.86882611, -77.05847435 38.87002898, -77.05786152 38.87261877), (-77.05579215 38.87026286, -77.05491238 38.87087264, -77.05544882 38.87170794, -77.05669337 38.87156594, -77.05684357 38.87072228, -77.05579215 38.87026286))";
Building *buildingObject = [Building new];
buildingObject.name = @"Pentagon";
buildingObject.shape = [BLPolygon fromWkt:pentagonPolygonString];
[[Backendless.shared.data of:[Building class]] saveWithEntity:buildingObject responseHandler:^(Building *savedBuilding) {
NSString *objectId = savedBuilding.objectId;
} errorHandler:^(Fault *fault) {
NSLog(@"Error: %@", fault.message);
}];
Building class:
@objcMembers class Building: NSObject {
var objectId: String?
var name: String?
var shape: BLPolygon?
}
let pentagonPolygonString = "POLYGON (" +
"(-77.05786152 38.87261877, " +
"-77.0546978 38.87296123, " +
"-77.05317431 38.87061405, " +
"-77.0555883 38.86882611, " +
"-77.05847435 38.87002898, " +
"-77.05786152 38.87261877), " +
"(-77.05579215 38.87026286, " +
"-77.05491238 38.87087264, " +
"-77.05544882 38.87170794, " +
"-77.05669337 38.87156594, " +
"-77.05684357 38.87072228, " +
"-77.05579215 38.87026286))"
if let pentagonBuildingShape = BLPolygon.fromWkt(pentagonPolygonString) {
let buildingObject = Building()
buildingObject.name = "Pentagon"
buildingObject.shape = pentagonBuildingShape
Backendless.shared.data.of(Building.self).save(entity: buildingObject, responseHandler: { savedBuilding in
guard let savedBuilding = savedBuilding as? Building else { return }
let objectId = savedBuilding.objectId
}, errorHandler: { fault in
print("Error: \(fault.message ?? "")")
})
}
NSString *pentagonPolygonString = @"POLYGON ((-77.05786152 38.87261877, -77.0546978 38.87296123, -77.05317431 38.87061405, -77.0555883 38.86882611, -77.05847435 38.87002898, -77.05786152 38.87261877), (-77.05579215 38.87026286, -77.05491238 38.87087264, -77.05544882 38.87170794, -77.05669337 38.87156594, -77.05684357 38.87072228, -77.05579215 38.87026286))";
BLPolygon *pentagonBuildingShape = [BLPolygon fromWkt:pentagonPolygonString];
NSDictionary *buildingObject = @{@"name": @"Pentagon", @"shape": pentagonBuildingShape};
[[Backendless.shared.data ofTable:@"Building"] saveWithEntity:buildingObject responseHandler:^(NSDictionary *savedBuilding) {
NSString *objectId = savedBuilding[@"objectId"];
} errorHandler:^(Fault *fault) {
NSLog(@"Error: %@", fault.message);
}];
let pentagonPolygonString = "POLYGON (" +
"(-77.05786152 38.87261877, " +
"-77.0546978 38.87296123, " +
"-77.05317431 38.87061405, " +
"-77.0555883 38.86882611, " +
"-77.05847435 38.87002898, " +
"-77.05786152 38.87261877), " +
"(-77.05579215 38.87026286, " +
"-77.05491238 38.87087264, " +
"-77.05544882 38.87170794, " +
"-77.05669337 38.87156594, " +
"-77.05684357 38.87072228, " +
"-77.05579215 38.87026286))"
if let pentagonBuildingShape = BLPolygon.fromWkt(pentagonPolygonString) {
let buildingObject = ["name": "Pentagon", "shape": pentagonBuildingShape] as [String : Any]
Backendless.shared.data.ofTable("Building").save(entity: buildingObject, responseHandler: { savedBuilding in
let objectId = savedBuilding["objectId"] as? String
}, errorHandler: { fault in
print("Error: \(fault.message ?? "")")
})
}
Notice the example above uses the BLPolygon.fromWKT
method to convert a string representation of a geometry into an instance of the BLPolygon
class. Alternatively, the code can use a constructor in the Polygon
class which accepts two collections - the boundary points and the holes. The example below and the one above produce exactly the same result using different approaches available in the SDK:
Building class:
@interface Building : NSObject
@property (strong, nonatomic) NSString *objectId;
@property (strong, nonatomic) NSString *name;
@property (strong, nonatomic) BLPolygon *shape;
@end
NSMutableArray *boundary = [NSMutableArray new];
[boundary addObject:[[BLPoint alloc] initWithLongitude:-77.05786152 latitude:38.87261877]];
[boundary addObject:[[BLPoint alloc] initWithLongitude:-77.0546978 latitude:38.87296123]];
[boundary addObject:[[BLPoint alloc] initWithLongitude:-77.05317431 latitude:38.87061405]];
[boundary addObject:[[BLPoint alloc] initWithLongitude:-77.0555883 latitude:38.86882611]];
[boundary addObject:[[BLPoint alloc] initWithLongitude:-77.05847435 latitude:38.87002898]];
[boundary addObject:[[BLPoint alloc] initWithLongitude:-77.05786152 latitude:38.87261877]];
NSMutableArray *holes = [NSMutableArray new];
[holes addObject:[[BLPoint alloc] initWithLongitude:-77.05579215 latitude:38.87026286]];
[holes addObject:[[BLPoint alloc] initWithLongitude:-77.05491238 latitude:38.87087264]];
[holes addObject:[[BLPoint alloc] initWithLongitude:-77.05544882 latitude:38.87170794]];
[holes addObject:[[BLPoint alloc] initWithLongitude:-77.05669337 latitude:38.87156594]];
[holes addObject:[[BLPoint alloc] initWithLongitude:-77.05684357 latitude:38.87072228]];
[holes addObject:[[BLPoint alloc] initWithLongitude:-77.05579215 latitude:38.87026286]];
Building *buildingObject = [Building new];
buildingObject.name = @"Pentagon";
buildingObject.shape = [[BLPolygon alloc] initWithBoundary:[[BLLineString alloc] initWithPoints:boundary] holes:[[BLLineString alloc] initWithPoints:holes]];
[[Backendless.shared.data of:[Building class]] saveWithEntity:buildingObject responseHandler:^(Building *savedBuilding) {
NSString *objectId = savedBuilding.objectId;
} errorHandler:^(Fault *fault) {
NSLog(@"Error: %@", fault.message);
}];
Building class:
@objcMembers class Building: NSObject {
var objectId: String?
var name: String?
var shape: BLPolygon?
}
var boundary = [BLPoint]()
boundary.append(BLPoint(longitude: -77.05786152, latitude: 38.87261877))
boundary.append(BLPoint(longitude: -77.0546978, latitude: 38.87296123))
boundary.append(BLPoint(longitude: -77.05317431, latitude: 38.87061405))
boundary.append(BLPoint(longitude: -77.0555883, latitude: 38.86882611))
boundary.append(BLPoint(longitude: -77.05847435, latitude: 38.87002898))
boundary.append(BLPoint(longitude: -77.05786152, latitude: 38.87261877))
var holes = [BLPoint]()
holes.append(BLPoint(longitude: -77.05579215, latitude: 38.87026286))
holes.append(BLPoint(longitude: -77.05491238, latitude: 38.87087264))
holes.append(BLPoint(longitude: -77.05544882, latitude: 38.87170794))
holes.append(BLPoint(longitude: -77.05669337, latitude: 38.87156594))
holes.append(BLPoint(longitude: -77.05684357, latitude: 38.87072228))
holes.append(BLPoint(longitude: -77.05579215, latitude: 38.87026286))
let pentagonBuildingShape = BLPolygon(boundary: BLLineString(points: boundary), holes: BLLineString(points: holes))
let buildingObject = Building()
buildingObject.name = "Pentagon"
buildingObject.shape = pentagonBuildingShape
Backendless.shared.data.of(Building.self).save(entity: buildingObject, responseHandler: { savedBuilding in
guard let savedBuilding = savedBuilding as? Building else { return }
let objectId = savedBuilding.objectId
}, errorHandler: { fault in
print("Error: \(fault.message ?? "")")
})
NSMutableArray *boundary = [NSMutableArray new];
[boundary addObject:[[BLPoint alloc] initWithLongitude:-77.05786152 latitude:38.87261877]];
[boundary addObject:[[BLPoint alloc] initWithLongitude:-77.0546978 latitude:38.87296123]];
[boundary addObject:[[BLPoint alloc] initWithLongitude:-77.05317431 latitude:38.87061405]];
[boundary addObject:[[BLPoint alloc] initWithLongitude:-77.0555883 latitude:38.86882611]];
[boundary addObject:[[BLPoint alloc] initWithLongitude:-77.05847435 latitude:38.87002898]];
[boundary addObject:[[BLPoint alloc] initWithLongitude:-77.05786152 latitude:38.87261877]];
NSMutableArray *holes = [NSMutableArray new];
[holes addObject:[[BLPoint alloc] initWithLongitude:-77.05579215 latitude:38.87026286]];
[holes addObject:[[BLPoint alloc] initWithLongitude:-77.05491238 latitude:38.87087264]];
[holes addObject:[[BLPoint alloc] initWithLongitude:-77.05544882 latitude:38.87170794]];
[holes addObject:[[BLPoint alloc] initWithLongitude:-77.05669337 latitude:38.87156594]];
[holes addObject:[[BLPoint alloc] initWithLongitude:-77.05684357 latitude:38.87072228]];
[holes addObject:[[BLPoint alloc] initWithLongitude:-77.05579215 latitude:38.87026286]];
BLPolygon *pentagonBuildingShape = [[BLPolygon alloc] initWithBoundary:[[BLLineString alloc] initWithPoints:boundary] holes:[[BLLineString alloc] initWithPoints:holes]];
NSDictionary *buildingObject = @{@"name": @"Pentagon", @"shape": pentagonBuildingShape};
[[Backendless.shared.data ofTable:@"Building"] saveWithEntity:buildingObject responseHandler:^(NSDictionary *savedBuilding) {
NSString *objectId = savedBuilding[@"objectId"];
} errorHandler:^(Fault *fault) {
NSLog(@"Error: %@", fault.message);
}];
var boundary = [BLPoint]()
boundary.append(BLPoint(longitude: -77.05786152, latitude: 38.87261877))
boundary.append(BLPoint(longitude: -77.0546978, latitude: 38.87296123))
boundary.append(BLPoint(longitude: -77.05317431, latitude: 38.87061405))
boundary.append(BLPoint(longitude: -77.0555883, latitude: 38.86882611))
boundary.append(BLPoint(longitude: -77.05847435, latitude: 38.87002898))
boundary.append(BLPoint(longitude: -77.05786152, latitude: 38.87261877))
var holes = [BLPoint]()
holes.append(BLPoint(longitude: -77.05579215, latitude: 38.87026286))
holes.append(BLPoint(longitude: -77.05491238, latitude: 38.87087264))
holes.append(BLPoint(longitude: -77.05544882, latitude: 38.87170794))
holes.append(BLPoint(longitude: -77.05669337, latitude: 38.87156594))
holes.append(BLPoint(longitude: -77.05684357, latitude: 38.87072228))
holes.append(BLPoint(longitude: -77.05579215, latitude: 38.87026286))
let pentagonBuildingShape = BLPolygon(boundary: BLLineString(points: boundary), holes: BLLineString(points: holes))
let buildingObject = ["name": "Pentagon", "shape": pentagonBuildingShape] as [String : Any]
Backendless.shared.data.ofTable("Building").save(entity: buildingObject, responseHandler: { savedBuilding in
let objectId = savedBuilding["objectId"] as? String
}, errorHandler: { fault in
print("Error: \(fault.message ?? "")")
})
Codeless Reference
The example below creates a new object containing one GeoJSON (Polygon
) object and saves it to the database called geolocation
:
where:
Argument | Description |
---|---|
table name |
Name of the data table where a new record must be saved. |
object |
An object to save in the database. Object properties must match the names of the table columns. The object must not have the objectId property. |
return result |
Optional parameter. When this box is checked, the operation returns the saved object with the objectId property. |
After running the code(or Codeless Logic), you will see the following object in the database: