Array or String Field in Searching with Nodejs

Hello,

I have 20 DBs (JSON Files)
I am using vuejs for frontend + nodejs & mongo for backend

I have some JSON DB store phone number as an array and another JSON DB store them as number filed
the same case with email filed some with array and some with string filed

Is there any difference in searching query for array and data filed?
Which the best case to use ( Convert data filed to an array or the opposite)?
My app focuses on reading most of the time not on an update or create or delete

Thanks

Hello @Osama_Al-Tahish, I suggest you post a sample (example) document with the data you want to discuss and looking for some ideas about its representation. It is little difficult to understand without the actual data.

Is there any difference in searching query for array and data filed?

MongoDB Query Language (MQL) and the Aggregation Framework has operators to work with (i.e., query) the array fields as per your needs. In general, there is not much difference - you just query the data, and you use different operators for these purpose.

Also, when thinking about array fields, since these are embedded within a document, you need to consider the MongoDB document size limit of 16 MB. It is good practice to know ahead the actual maximum size (the number of elements) of the array when you are designing your application.

1 Like