Manuel Reis
Manuel Reis

Reputation: 574

Join document by field that is not a primary key

I have an external system that creates documents (orders) on my platform. The reference to my platform is maintained through a string code, which is not a primary key. So, I have the following entities:

{
    docType: "submission",
    code: "XPTO28",
    name: "test-sub"
}

{
    docType: "order",
    code: "XPTO28",
    value: "100$"
}

Is there any query to associate order documents to submission documents without using primary keys, or must I do so programatically?

Upvotes: 0

Views: 218

Answers (1)

Simon Baslé
Simon Baslé

Reputation: 28341

You have to do it programatically. Joins in N1QL are currently limited to linking a field (or something that can be reconstructed from a field, eg. concatenating a prefix) to the primary key of the joined keyspace.

Upvotes: 1

Related Questions