go-cloud icon indicating copy to clipboard operation
go-cloud copied to clipboard

docstore: array contains query

Open eqinox76 opened this issue 4 years ago • 2 comments

Is your feature request related to a problem? Please describe.

I have a n:m relation between documents in two collections A, B. I would like to retrieve all documents from collection B which relate to one specific document in A. With the supported filter options i am not able to do such a query.

Describe the solution you'd like

It seems all supported databases support a array contains search. This way i could store a list of ids in each document in B and query easily for them.

Describe alternatives you've considered

  • Create a third collection where the relations are stored in minimal documents {A: "123", B: "DEF"}. Hard to keep in sync.
  • Request every document and filter locally. Wasteful when i cannot reduce the result set.
  • Keeping a local cache of the relation. Will need notification and invalidation between processes.

Additional context

Here are the links to the supported array contains queries mongodb firestore dynamodb cosmosdb

eqinox76 avatar Jun 25 '20 14:06 eqinox76

@jba any comment on this?

vangent avatar Jun 25 '20 17:06 vangent

Any progress on this feature?

ybourgery avatar Mar 15 '21 10:03 ybourgery

+1 for this feature. It seems like all the underlying databases (except for memdatastore) support queries like this.

The docstore query api on go-cloud is surprisingly limited. Since this isn't supported at this time, it seems we have to As() to the specific clients and maybe rely on our own adapter for queries like this.

coryschwartz avatar Apr 22 '23 03:04 coryschwartz

Fixed!

vangent avatar Dec 28 '23 07:12 vangent