I have collection of Users with unique property UserName. I need to insert in this collection array of Users. But if UserNames are equal I need to replace old document with the new one. (for each user)
Can be done this by one operation?
Related
I actually want To display Full documents Without duplication
When I use distinct i can only display one particular field
How to display all fields without selecting that document which is repeated
Each document in MongoDB contains an _id field which must be unique in the collection. Hence, it is not possible to have two identical documents in a collection. Ergo, iterating a collection with no conditions will return all unique documents (which are all documents in the collection).
I am trying to create a collection name based on the date like i have a collection name like this Change 06-05-2020 and i want to overwrite this collection daily and make the collection name like this Change 07-05-2020 and so on is it possible to do it i ma creating the collection in this way.and basically i am trying to store the daily updated data in a particular way so i can track that information.so can i update the collection name dynamically daily?
await growthfilemsdb.collection(`Change${getISO8601Date()}`).doc(change.after.data().officeId).set(change.after.data(),{merge:false})
It's not possible to change the name of a collection. What you can do instead is simply copy all the documents from the old collection to a new one with a new name.
However, it's usually not a good idea to make the names of your collection dynamic like this. Instead, consider putting the date as a field inside the document, and using that to filter the results of queries or delete old documents.
I have a collection which stores document that can have multiple subdocument (e.g. a group collection with multiple votings). My goal is to delete certain subdocuments on a certain date. I thought about using a package like "agenda" to cron-like delete certain subdocuments. Are there any more efficient or easier ways to do that
For a dating site I have a db of hundreds of different Users.
Fields such as "matches", "heartedMe" contain the ObjectId of different users in Array form.
When I delete a user I need to search every collection and delete any references to the deleted user by $pull ing their ObjectId from all relevant fields.
Any thoughts on the sort of query I would need to run? Currently I've just found All Users!
Thanks a lot!
I'm new to Firestore so I have a simple question:
Suppose I have a collection of users and a collection of groups. users have an array field of groupReferences to mark what groups it is a part of.
Now I want to query a subset of the collection of groups that matches those that a particular user is within.
Do I:
Pull all groups and somehow compare the references in the user, filtering out any that match?
Iterate through the user's references and pull each group one at a time?
Thanks for your help!