Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

insertMany with large data #8420

Closed
Navyroot opened this issue Dec 11, 2019 · 4 comments
Closed

insertMany with large data #8420

Navyroot opened this issue Dec 11, 2019 · 4 comments
Labels
needs clarification This issue doesn't have enough information to be actionable. Close after 14 days of inactivity

Comments

@Navyroot
Copy link

Navyroot commented Dec 11, 2019

I try to insert data with insertMany in Mongoose .

console.log('Starting...')
let data = JournalDetails.find().lean()
    // data maybe over 80000
    JournalDetails.deleteMany({})
    JournalDetails.insertMany(data)
console.log('done Journal details!')

but it alway execute two time when call it(1 time) .
Screen Shot 2019-12-11 at 3 59 09 PM

Version

  • Mongoose version 5.7.1
  • Mongo version 4.0.10
  • Node version 8.11.3
  • Meteor version 1.8.1
@AbdelrahmanHafez
Copy link
Collaborator

My first guess would be that this is an issue with the code calling this code snippet, since the console.log(...); runs twice, this has nothing to do with mongoose. If you could provide a reproduction script that would be very helpful.

@Navyroot
Copy link
Author

  • Code Server Side
export const migrateDataDecimal = new ValidatedMethod({
 name: 'app.migrateDataDecimal',
 mixins: [CallPromiseMixin],
 validate: null,
 async run() {
   if (Meteor.isServer) {
     console.log('Starting...');
     let data
     data = await Journals.find().lean()
     await Journals.deleteMany({})
     await Journals.insertMany(data)
     console.log('done Journal!');
     return `Success`
   }
 },
})
  • Code Client Side
    I called it from client side
// methods on client
migrateData() {
      this.loading = true
      migrateDataDecimal
        .callPromise()
        .then(res => {
          this.loading = false
          console.log('res', res)
        })
        .catch(err => {
          this.loading = false
          console.log('err', err)
        })
}

@AbdelrahmanHafez
Copy link
Collaborator

It's not easy for me to reproduce using a client side/server side code kind of thing. There is a lot that could change in my setup that would make my test inaccurate.

Can you abstract your code in a single script that reproduces the issue? An example would look like the first code snippet in #8371 (comment).

@vkarpov15
Copy link
Collaborator

So what exactly is the issue here? It looks like your code runs twice, and one of those times it takes longer to execute than the other. Is that the problem, or do you not expect the code to run twice?

@vkarpov15 vkarpov15 added the needs clarification This issue doesn't have enough information to be actionable. Close after 14 days of inactivity label Dec 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs clarification This issue doesn't have enough information to be actionable. Close after 14 days of inactivity
Projects
None yet
Development

No branches or pull requests

3 participants