Closed imtrobin closed 5 years ago
@imtrobin if you mean composite primary key, then arangodb has not one. either you should somehow concatenate attributes to build _key
attribute, or use a unique hash index on multiple attributes
. which i think the later one is better in most cases
I don't think I can use either alternative, because the _key must be immutable. For example, the email can be changed so then, that would change the _key too on hash if its bult from attributes. So I would still have to lookup the db to find the _key from the email.
_key
is immutable and cant be changed after document is created, why unique hash index
wont work for you?
{
"_key":"3412342",
// unique hash index on email attribute
"email":"some@mail.com"
}
It will work, but as an example, I have to get the _key first. E.g to update a user, the user is gonna pass me his email username, not _key, so I will need to
@imtrobin you can also update(upsert/insert/remove) a document with a filter expression and not retrieve it from database
I did it with an index using ByExample. The examples still requires the key.
Hi, is there a way to support custom index instead of _key? In more advanced cases, e.g for creating an authentication system using email, I would not be using the email as the key as I would allow the user to change email in future.
I can create an skiplist index on Email, so I can pass that in, but in the current form, just supporting _key, it means I have to do a search in db to get the _key first.