First I created the mongoose schema:
var cardSchema = mongoose.Schema({
**userId: String,
imageUrl: String**
})
Then I defined model:
var Card = mongoose.model('Card', cardSchema)
Then I created a new card:
var newCard = new Card({
**userId: "bablaba"**
});
Then the new card is saved correctly(I tested):
newCard.save(function(err,theC ard){
if(err) return console.log(err);
console.log("saved");
console.log(theCard);
})
Now I need to update information in the card. I want to add/insert imageUrl into the saved new card. Here's a few ways I tried:
1.
Card.where({ _id: _id }).update({
$set: {imageUrl:"blablab"}
});
2.
Card.update(_id,{$set:{imageUr l:"balbalab"}})
3.
Card.update({_id: updateInfo._id}, {note0:updateInfo.note0, note1: updateInfo.note1},{multi:true} , function(err, numberAffected){});
None of these three worked!!! Please help..
댓글 없음:
댓글 쓰기