README
Anysols Core Service
Anysols Core Service takes care data handling of the anysols platform
Starting core service
const coreService = require('@anysols/anysols-core-service');
const coreService = new AnysolsCoreService({
"host": "localhost",
"port": "27017",
"database": "anysols-core-service-demo",
"dialect": "mongodb",
}
);
coreService.start().then(() => {
console.log("Core service is up and running");
setTimeout(function () {
console.log("Stopping core service after 10 seconds");
coreService.stop().then(() => {
console.log("Core service shutdown successfully");
});
}, 10000);
}, function (err) {
console.log(err.message);
});
Defining schema and querying collection
const coreAPI = coreService.getAPI();
coreAPI.defineCollection({
name: 'student',
fields: [{
name: 'name',
type: 'string'
}, {
name: 'computed',
type: 'string'
}, {
name: 'testing',
type: 'string'
}]
});
let studentCol = coreAPI.collection("student");
let s = studentCol.createNewRecord();
s.set("name", "John");
s.set("computed", "John");
s.set("testing", "John");
s.insert().then(function () {
studentCol.find({}).toArray().then(function (students) {
console.log(JSON.stringify(students, null, 4));
coreService.stop().then(function () {
console.log("Platform shutdown successfully");
});
});
});