我正在构建一个 node js 应用程序和 OrientDB 作为数据库。有没有办法像使用 MongoDB 那样为节点中的顶点创建模型?
例如,我有一个名为 Account 的类,其中包含属性名称、密码和电子邮件。
使用 OrientDB 和 OrientJS 作为语言驱动程序时,是否可以在节点中为此创建模型?
感谢任何帮助。
我不知道我是否理解正确,但这是创建您描述的类的方法:
var OrientDB = require('orientjs');
var server = OrientDB({
host: 'localhost',
port: 2424,
username: '<username>',
password: '<password>'
})
var db = server.use({
name: 'mydb',
username: '<username>',
password: '<password>'
})
db.class.get('Account')
.then(function (MyClass) {
MyClass.property.create([{
name: 'name',
type: 'String'
},{
name: 'password',
type: 'String'
},{
name: 'email',
type: 'String'
}])
.then(function () {
console.log('Properties created')
});
})
server.close();
希望能帮助到你
问候
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句