I am using orientjs version: 2.1.0 and orientdb version 2.1.6 community edition
From the github docs I found that there are 2 ways to create a new Vertex.
Here is the first method
db.create('VERTEX', 'User')
.set(newUser)
.one()
.then(function (record) {
logger.info("Created record " + record)
return resolve(record)
}).catch(function (err) {
logger.error("Error in creating user ");
logger.error(err);
return reject(err)
})
And here is the second method
var User = db.class.get("User").then(function (User) {
User.create(newUser).then(function (record) {
logger.info("Created record " + record)
return resolve(record)
})
}).catch(function (err) {
logger.error("Error in creating user ");
logger.error(err);
return reject(err)
})
So which is the preferred method and why? And when to use db.create and class.create?
I think the first method is a bit more faster because there is only one call to the db. Correct me if I am wrong.