Skip to content

Instantly share code, notes, and snippets.

@lineus lineus/irfaan.js Secret
Created Mar 22, 2018

What would you like to do?
use .update() query builder method
#!/usr/bin/env node
'use strict'
const mongoose = require('mongoose')
const Schema = mongoose.Schema
const schema = new Schema({
name: String
const Test = mongoose.model('test', schema)
const test = new Test({
name: 'Jimmy Hendrix'
async function run () {
await Test.remove({})
await Test.create(test)
await Test.findOne({ _id: test._id })
.update({ name: 'Jimi Hendrix' })
let doc = await Test.findOne({ _id: test._id })
return mongoose.connection.close()
gitter: ./irfaan.js
Jimi Hendrix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.