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.

2
  • 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... Commented Dec 3, 2018 at 21:18
  • i find the solution from stackoverflow.com/questions/41834360/… Commented Dec 4, 2018 at 15:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.