Backendless在API Services返回数据库对象方面有以下规则:
Properties
参数来指定返回的属性列表。例如,以下代码将只返回name
和age
属性:Backendless.Data.of("Person").find({
properties: ["name", "age"]
}).then(function(response) {
console.log(response);
}).catch(function(error) {
console.error(error);
});
relations
参数来指定返回关联对象的信息。例如,以下代码返回Person
对象及其关联的Address
对象的完整信息:Backendless.Data.of("Person").find({
relations: ["Address"]
}).then(function(response) {
console.log(response);
}).catch(function(error) {
console.error(error);
});
pageSize
和offset
参数来分页返回结果。pageSize
指定每页返回的对象数量,offset
指定从哪个位置开始返回。例如,以下代码返回第一页的10个Person
对象:Backendless.Data.of("Person").find({
pageSize: 10,
offset: 0
}).then(function(response) {
console.log(response);
}).catch(function(error) {
console.error(error);
});
where
参数来指定返回符合特定条件的对象。例如,以下代码返回age
大于等于18的Person
对象:Backendless.Data.of("Person").find({
where: "age >= 18"
}).then(function(response) {
console.log(response);
}).catch(function(error) {
console.error(error);
});
请根据您的需求选择适当的规则和参数来返回数据库对象。请注意,以上示例代码是使用JavaScript进行的示范,您可以根据您使用的编程语言进行适当的调整。