#community-help

Querying by ID Using GTIN in a Collection

TLDR Julian asks if it's possible to query by ID using GTIN. Jason suggests creating a separate field called gtin and using that in query_by.

Powered by Struct AI
+11
5
4mo
Solved
Join the chat
May 15, 2023 (4 months ago)
Julian
Photo of md5-309edd752adeb3e0ea515a8c8165ce45
Julian
02:07 PM
In the risk of asking a dummy question: Is it possible to query_by id? I have a collection with food records and I have used the GTIN as id. Now I want to be able to query by GTIN.
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
02:37 PM
id is a special field used internally, so it can’t be used in query_by. You would have to create another field called say gtin and use that in query_by
Julian
Photo of md5-309edd752adeb3e0ea515a8c8165ce45
Julian
02:39 PM
And it's not considered an anti-pattern to have the same piece of information appearing twice within one document?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
02:40 PM
Not in the case of ID
Julian
Photo of md5-309edd752adeb3e0ea515a8c8165ce45
Julian
02:40 PM
Got it, thanks :saluting_face:
+11