1

i am facing problem when i insert array of object in mongodb

myarray = [
{ id: 213,
name: 'MonaCoin',
symbol: 'MONA',
price: 0.629564688986,
volume: 2226709.2039523,
last_update: '2018-12-03T18:45:04.000Z' },
{ id: 1169,
name: 'PIVX',
symbol: 'PIVX',
price: 0.706248118629,
volume: 310213.338790205,
last_update: '2018-12-03T18:45:08.000Z' },
{ id: 2062,
name: 'Aion',
symbol: 'AION',
price: 0.1502951806,
volume: 1827674.44495399,
last_update: '2018-12-03T18:45:17.000Z' },
{ id: 1727,
name: 'Bancor',
symbol: 'BNT',
price: 0.655718694418,
volume: 1598779.80773313,
last_update: '2018-12-03T18:45:11.000Z' }
]

and the function i used are "insertmany" "create" and "save" function:

myschema.insertmany(myarray,(err,obj)=>{
console.log("saved"obj) 
})

it show saved but no data saved in mongodb, please tell me what is the best approach for this scenario.

rohai789
  • 15
  • 3
  • Assuming that the `("saved"obj)` is a typo (the `obj` should not be there), you're not doing anything wrong here but you are probably looking at the wrong server, database and/or collection... – dnickless Dec 03 '18 at 21:18
  • i find the solution from https://stackoverflow.com/questions/41834360/how-to-save-array-of-json-object-to-mongoose – rohai789 Dec 04 '18 at 15:22

0 Answers0