Will join work with alias? For e.g. can "products"...
# community-help
n
Will join work with alias? For e.g. can "products" be an alias for the other collection in the following reference syntax?
Copy code
{
  "name": "product_id",
  "type": "string",
  "reference": "products.product_id"
}
k
Yes it works
n
Thanks @Kishore Nallan If we update the alias to point to a new collection, will the reference get updated to the new collection? Or will the update alias operation fail?
j
The mapping between an alias and collection name is stored at the alias level, and resolved at query time. So updating the alias to a new collection name, will make queries from that point on that use the same alias to use the new collection going forward
👍 1
k
Actually, alias with reference is a bit tricky. For joins, the reference collection documents stores the internal ids of the documents that it is joined with in the schema. So when you switch the alias to another collection, these internal IDs will not match unless both the collections were indexed with documents in the same order (i.e. because the internal IDs are sequential in nature). What this means: have to treat all referenced collections as a group. Must reindex all of them at one go if you plan to switch any one of them via alias, you've to do all.
👍 1
n
@Kishore Nallan Is there a way for us to decide the internal id value?