1.5.8 • Published 5 years ago

@plt4rm/service-database v1.5.8

Weekly downloads
1
License
Apache-2.0
Repository
github
Last release
5 years ago

Service Database

Database Service takes care data handling in plt4rm

Build Coverage Status

Starting core service

const P4DatabaseService = require('@plt4rm/service-database');

const dbService = new P4DatabaseService({
        "host": "localhost",
        "port": "27017",
        "database": "service-database-example",
        "dialect": "mongodb",
    }
);

dbService.start().then(() => {
    console.log("Core service is up and running");
    setTimeout(function () {
        console.log("Stopping core service after 10 seconds");
        dbService.stop().then(() => {
            console.log("Core service shutdown successfully");
        });
    }, 10000);
}, function (err) {
    console.log(err.message);
});

Defining schema and querying collection

const coreAPI = dbService.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));
        dbService.stop().then(function () {
            console.log("Platform shutdown successfully");
        });
    });
});

Code of Conduct

Contributor Covenant

License

Apache License 2.0

1.5.8

5 years ago

1.5.7

5 years ago

1.5.5

5 years ago

1.5.4

5 years ago

1.5.6

5 years ago

1.5.3

5 years ago

1.5.2

5 years ago

1.5.1

5 years ago

1.5.0

5 years ago

1.4.9

5 years ago

1.4.8

5 years ago

1.4.7

5 years ago

1.4.6

5 years ago

1.4.5

5 years ago

1.4.3

5 years ago

1.4.2

5 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.5

5 years ago

1.3.4

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.6

5 years ago

1.2.5

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago