在 node.js 中为 OrientDB 数据库创建模型
Create a model for OrientDB database in node.js
我正在构建一个节点 js 应用程序和 OrientDB 作为数据库。有没有办法像我们使用 MongoDB?
一样为节点中的顶点创建模型
例如,我有一个名为 class 的帐户,其中包含属性名称、密码和电子邮件。
在使用OrientDB和OrientJS作为语言驱动时,是否可以在节点中为此创建一个模型?
感谢任何帮助。
我不知道我是否理解正确,但这是创建您描述的 class 的方法:
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();
希望对您有所帮助
此致
我正在构建一个节点 js 应用程序和 OrientDB 作为数据库。有没有办法像我们使用 MongoDB?
一样为节点中的顶点创建模型例如,我有一个名为 class 的帐户,其中包含属性名称、密码和电子邮件。
在使用OrientDB和OrientJS作为语言驱动时,是否可以在节点中为此创建一个模型?
感谢任何帮助。
我不知道我是否理解正确,但这是创建您描述的 class 的方法:
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();
希望对您有所帮助
此致