Skip to content

Instantly share code, notes, and snippets.

@lineus lineus/output.txt Secret
Created Jul 1, 2018

Embed
What would you like to do?
example
$: ./szun.js
{ _id: 5b38d2ff775fd51d1b11b479, name: 'szun', __v: 0 }
$:
#!/usr/bin/env node
'use strict';
const mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/szun');
const conn = mongoose.connection;
const Schema = mongoose.Schema;
const schema = new Schema({
name: String
});
const Test = mongoose.model('test', schema);
const test = new Test({
name: 'szun'
});
async function run() {
await test.save();
let doc = await Test.findOne();
console.log(doc);
return conn.close();
}
run();
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.