Simple Object Graph Mapper based on ES6 classes and using ES7 decorators.
Install via npm.
npm install ogmTo run the test suite, first invoke the following command within the repo, installing the development dependencies:
npm installThen run the tests:
npm test- Using official OrientDB driver for node.js orientjs.
- Intuitive API, based on next gen javascript.
import * as ogm from 'ogm';
var server = ogm.connect({
host: 'localhost',
port: 2424,
username: 'root',
password: 'yourpassword'
});var db = ogm.use('mydb');
console.log('Using database: ' + db.name);var db = ogm.use({
name: 'mydb',
username: 'admin',
password: 'admin'
});
console.log('Using database: ' + db.name);@ogm.model("Person")
class Person extends ogm.V {
@ogm.property(String)
name = this.name;
@ogm.property(Number)
age = this.age;
}var john = new Person({name: 'John'});
// Saving new instance
await john.save();
// Editing properties
john.age = 12;
//Saving changes
await john.save();
//Deleting instance
await john.delete();var john = await Person.query({name: 'John'}).one();
// Getting by rid
var john = await Person.get('#1:1');