ogm
Version:
OGM for OrientDB
108 lines (72 loc) • 1.58 kB
Markdown
Simple Object Graph Mapper based on ES6 classes and using ES7 decorators.
Install via npm.
```sh
npm install ogm
```
To run the test suite, first invoke the following command within the repo, installing the development dependencies:
```sh
npm install
```
Then run the tests:
```sh
npm test
```
- Using official OrientDB driver for node.js [orientjs](https://github.com/orientechnologies/orientjs).
- Intuitive API, based on next gen javascript.
```js
import * as ogm from 'ogm';
var server = ogm.connect({
host: 'localhost',
port: 2424,
username: 'root',
password: 'yourpassword'
});
```
```js
var db = ogm.use('mydb');
console.log('Using database: ' + db.name);
```
```js
var db = ogm.use({
name: 'mydb',
username: 'admin',
password: 'admin'
});
console.log('Using database: ' + db.name);
```
```js
@ogm.model("Person")
class Person extends ogm.V {
@ogm.property(String)
name = this.name;
@ogm.property(Number)
age = this.age;
}
```
```js
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();
```
```js
var john = await Person.query({name: 'John'}).one();
// Getting by rid
var john = await Person.get('#1:1');
```