Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to coerce string to RecordID #396

Open
grimace opened this issue Oct 25, 2019 · 2 comments
Open

how to coerce string to RecordID #396

grimace opened this issue Oct 25, 2019 · 2 comments
Assignees

Comments

@grimace
Copy link

grimace commented Oct 25, 2019

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?

@wolf4ood
Copy link
Member

Hi @grimace

how are you updating the vertex ?

Thanks

@wolf4ood wolf4ood self-assigned this Oct 29, 2019
@grimace
Copy link
Author

grimace commented Oct 29, 2019

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);
          });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants