1.1.0 • Published 4 years ago

@anysols/anysols-core-service v1.1.0

Weekly downloads
2
License
Apache-2.0
Repository
github
Last release
4 years ago

Anysols Core Service

Anysols Core Service takes care data handling of the anysols platform

Coverage Status

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");
        });
    });
});

Code of Conduct

Contributor Covenant

License

Apache License 2.0