A
A
Alexey2019-03-13 15:53:23
MongoDB
Alexey, 2019-03-13 15:53:23

MongoDB insertMany creates new collection instead of adding?

You need to add an array of objects to an already existing collection. I am using this code:

catModel.insertMany(jsonRow,  function(err, videos) {

Inside catModel there is a modelName property: "Yoga-videos-source" Mongo has a collection called "Yoga-videos-source".
Problem: After inserting an array of objects, many are added not to "yoga-videos-source", but to a new collection named "yoga-videos-sources" (prefixed with -s at the end).
Question How can I fix this? Why did it happen?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey, 2019-03-14
@azovl

The main problem is that collections have names like: "Yoga-videos-source". Mongo has a specific collection naming convention, so the name should be: "yoga-videos-sources"
1) No capitalization 2) End should be "-s"

D
Dimonchik, 2019-03-13
@dimonchik2013

RAW request normally fulfills?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question