Can I insert multiple objects at once in firestore? in mongoDB db.collection.insert
we can insert an array of objects. Is it possible in firestore?
Asked
Active
Viewed 43 times
0

Unnikrishnan
- 2,683
- 5
- 22
- 39
-
Your question is saying two different things. The question title is asking if you can add multiple *documents* together, and the question body is asking about adding multiple *objects* at the same time. They are not the same thing - are you talking about documents or object fields within documents? – Doug Stevenson Apr 20 '19 at 17:40
-
@DougStevenson - documents in a collection. Adding array of documents like mongoDB is that possible? Sorry for my bad English. – Unnikrishnan Apr 20 '19 at 17:44
-
https://stackoverflow.com/questions/46618601/how-to-create-update-multiple-documents-at-once-in-firestore – Doug Stevenson Apr 20 '19 at 17:50
-
I found that answer simply by putting your question into a Google search. It was the first hit. – Doug Stevenson Apr 20 '19 at 17:50
-
It's saying about single batch, what I 'm asking here is something like `db.collection('users').add([user1, user2, user3, user4]);` is possible or not? – Unnikrishnan Apr 20 '19 at 17:58
-
A batch *is* multiple documents at the same time, which is what your question is asking. If that's not what you want, what specifically are you trying to accomplish? What is the end result of the database, after everything is done? – Doug Stevenson Apr 20 '19 at 18:01
-
I have an array of users, I want to add it together, don't want to insert one at a time. – Unnikrishnan Apr 20 '19 at 18:04
-
1Then pass an object that describes the entire set of data you want to insert into the single document. If you're still confused, you should ask a new question and fully describe what data you need to add, and what the final document should look like. – Doug Stevenson Apr 20 '19 at 18:06