问题
Is it possible to join two collections in JSONStore?
I want to access data from the given two collections in the json store one of which has a foreign key.
回答1:
There's nothing equivalent to a join
in Relational Databases for JSONStore. However, like Namfo said in the other answer, you may take advantage of additionalSearchFields
for this use case. It allows you to index values that are not part of the data being stored. For example, if you have a order
collection and are storing objects like {item: 'knife'}
you could have an additional search field for customer_id
which references an id
search field in the customer
collection. Here is a post that explains additional search fields.
回答2:
JSONSTORE does not have the ability to combine collections. However, you can use a common index between the two collections to access relevant data. For instance, order_id search field can be shared between the customer collection and order collection.
来源:https://stackoverflow.com/questions/28408301/joining-two-collections-in-json-store