walieeldin
walieeldin

Reputation: 38

db.collection.insertOne not working, is there something wrong with my code?

Ok, so here's some context. Basically, I'm making a Discord bot and I'm using Mongoose to store user data, like how much gold they have in their bank, but I've tried looking at tutorials and copying code (we're all guilty of it) but nothing seems to work. Here's my code:

const user = db.collection.insertOne({
    _id: mongoose.Types.ObjectId,
    guild: msg.guild.id,
    gold: 0,
})

Upvotes: 0

Views: 2853

Answers (2)

user12829430
user12829430

Reputation:

with mongodb command

db.collection.insert({...})

You can check it out here

OR

with mongoose

myModel.create({...})

You can check it out here

Upvotes: 1

d_bish
d_bish

Reputation: 13

insertOne is not available in mongoose

try reading more on this this answer of stackoverflow : insertOne is not a function

Upvotes: 1

Related Questions