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

Assign single UID to predicate #1519

Closed
calummoore opened this issue Sep 22, 2017 · 7 comments
Closed

Assign single UID to predicate #1519

calummoore opened this issue Sep 22, 2017 · 7 comments
Labels
kind/feature Something completely new we should consider.
Milestone

Comments

@calummoore
Copy link

calummoore commented Sep 22, 2017

As posted on the community forum:

It would be useful to be able to assign a uid to a predicate directly without adding it to a Posting List. For example, I might have a predicate teacher, where it is only ever possible to have one teacher at a time.

At the moment I would have to do the following to update the predicate, which means 2 round trips and is unnecessarily verbose.

mutation {
  delete  {
    <0x4> teacher * .
  }
}

mutation {
  set {
    <0x4> teacher <0x9> .
  }
}

Ideally, you would want to be able to specify in the schema that that predicate only accepts a single uid.

mutation {
  schema {
    teacher: uid @unary
  }
}

It would also have the added benefit of being able to return an object instead of an array when the unary predicate is being queried, as it would know there could only ever be one node/object.

@manishrjain
Copy link
Contributor

Once we support transactions, this is something that users can handle at their end.

Related issue: #1445

@manishrjain
Copy link
Contributor

manishrjain commented Oct 19, 2017

Think I was too quick to declare that txns would solve this. It would still require two round trips to first delete the edges, and then set one. So, the idea of having a @unary in the schema is a good one.

If it's not too complex to implement, we'll do so (in v0.9 series).

@manishrjain manishrjain added this to the v0.9.x milestone Oct 19, 2017
@manishrjain manishrjain added the kind/feature Something completely new we should consider. label Oct 19, 2017
@calummoore
Copy link
Author

Great news!

This will be really helpful, as there are a lot of instances where I want to reference a single node in a one-to-many relationship.

@pawanrawal pawanrawal modified the milestones: v0.9.x, v1.x Dec 6, 2017
@calummoore
Copy link
Author

Just thinking about this a bit more.

This feature would also enable efficient lookup of a uid by predicate, as there would only ever be one uid for a given node/predicate, performing a search would essentially the same as a hash lookup.

You could then add a new index / filter for that as well.

@manishrjain manishrjain added the kind/feature Something completely new we should consider. label Mar 22, 2018
@AlexDunmow
Copy link

Is this still on the cards?

@manishrjain
Copy link
Contributor

This looks like a duplicate of #2511.

@manishrjain
Copy link
Contributor

We're working on #2511 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Something completely new we should consider.
Development

No branches or pull requests

4 participants