3.2.0 • Published 9 years ago
neodm v3.2.0
Neo4j Graph Data Model
Also works with new bolt driver
Changes
3.2.0 : allow setRelationship & set to be used with simple object and not just Model instance or id
breaking: v3 no longer relies on neo4j id's and sets own id
property if not set in model declaration
Usage
Setup
const NeoDM = require('neodm');
NeoDM.db.setDB('http://localhost:7474');
NeoDM.db.setLogger(console.log);
Model Declaration
const Joi = require('joi');
const Model = NeoDM.Model;
Simple model declaration
class User extends Model {
static [Model.schema]() {
return {
username: Joi.string()
};
}
}
const johnData = { username: 'john' };
const john = new User(johnData);
yield john.save();
hasOne relationship
class User extends Model {
static [Model.schema]() {
return {
username: Joi.string()
};
}
}
class Article extends Model {
static [Model.schema]() {
return {
title: Joi.string().default('test'),
author: Model.hasOne(User)
};
}
}
const johnData = { username: 'john' };
const john = new User(johnData);
yield john.save();
const article = new Article({ title: 'hello world', author: john });
yield article.save();
find( {property:value, anotherProp:value} )
class User extends Model {
static [Model.schema]() {
return {
username: Joi.string()
};
}
}
const johnData = { username: 'john smith' };
const john = new User(johnData);
yield john.save();
const johnFromDB = yield User.find({ username: johnData.username });
find( id1, id2 )
const john = new User({ username: 'john' });
yield john.save();
const smith = new User({ username: 'smith' });
yield smith.save();
const users = yield User.find([smith.id, john.id]);
Full Model Declaration
class Author extends Model{
static [Model.schema](){
return {
name:Joi.string()
}
}
afterInit(){
//no return
}
afterInflate(inflatedRelationshipKeys){
return Promise;
}
beforeValidate(){
return Promise;
}
}
better see the tests
-signed gpg 3
3.2.0
9 years ago
3.1.5
9 years ago
3.0.5
9 years ago
3.0.2
9 years ago
3.0.1
9 years ago
3.0.0
9 years ago
1.4.7
9 years ago
1.4.6
9 years ago
1.3.6
9 years ago
1.3.5
9 years ago
1.3.4
10 years ago
1.3.3
10 years ago
1.3.2
10 years ago
1.3.1
10 years ago
1.3.0
10 years ago
1.2.23
10 years ago
1.2.22
10 years ago
1.2.21
10 years ago
1.2.20
10 years ago
1.2.18
10 years ago
1.2.17
10 years ago
1.2.16
10 years ago
1.2.15
10 years ago
1.2.14
10 years ago
1.2.13
10 years ago
1.2.12
10 years ago
1.2.10
10 years ago
1.2.9
10 years ago
1.2.8
10 years ago
1.2.7
10 years ago
1.2.6
10 years ago
1.2.5
10 years ago
1.2.3
10 years ago
1.2.2
10 years ago
1.2.1
10 years ago
1.2.0
10 years ago
1.1.0
10 years ago
1.0.0
10 years ago