nativescript-sqlite
nativescript-sqlite copied to clipboard
New Feature: Include()
I come from a web background where i have bee using EntityFramework alot. I think a nice feature would be to have an .include() function.
Essentially. what it would do it load another Query/Table into a variable into the first query. This helps to create Nested objects where a table join just doesnt do the same things.
Example of what im using right now:
read: function () {
if (global.isOnline()) {
return global.oversii.api.fetch.post("property")
.then((jsonData) => jsonData);
}
else {
return new Promise((resolve, reject) => {
db.context.all("SELECT * FROM Property")
.then((properties) => {
for (let i = 0; i <= properties.length - 1; i++) {
const property = properties[i];
db.tables.violationWorkflowPeriod.getById(property.ViolationWorkflowPeriodId)
.then((vwp) => {
property.ViolationWorkflowPeriod = vwp;
if (i === properties.length - 1) {
resolve(properties);
}
})
.catch((error) => db.error(error));
}
})
.catch((error) => db.error(error));
});
}
},