orientjs
orientjs copied to clipboard
how to coerce string to RecordID
I have a Vertex ( Data ) that has a tags field ( LINKLIST ) which I'm storing as recordIDs - in string format like this:
tags : [
"#306:2",
"#305:1"
]
When I update the Data Vertex I get an exception:
`The field 'Data.tags' has been declared as LINKLIST but the value is not a record or a record-id\r\n\tDB
I really don't want to expand and replace the Vertices before saving the record to the DB. Is there a way to coerce these to @RIDs?
Hi @grimace
how are you updating the vertex ?
Thanks
I'm using orientjs: in this, article contains a number of fields, there are 2 linklist fields:
content - has a list of RIDs for other Articles
tags - has a list of RIDs for Tags
res.locals.db.update(rid)
.set(article)
.one()
.then(update => {
console.log("Article updated - setting OwnsContent : "+rid+" , "+repo_id);
// let resultRid = update['@rid'];
res.locals.db.create("EDGE", "OwnsContent", "UPSERT")
.from(repo_id).to(rid)
.one()
.then(edge => {
console.log('created edge to repo : '+edge);
// article['@rid'] = rid;
cb(article);
}).catch(err => {
console.log('creating edge to repo failed for : '+rid);
});
})
.catch(err => {
console.log("Article update failed:", err);
error(err);
});