Skip to content

Instantly share code, notes, and snippets.

@lineus lineus/johncdf.js Secret
Created Jul 2, 2018

Embed
What would you like to do?
example
#!/usr/bin/env node
'use strict';
const mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/test');
const conn = mongoose.connection;
const Schema = mongoose.Schema;
const schema = new Schema({
email: String
});
const Test = mongoose.model('test', schema);
const test = new Test({
email: 'lineus@gmail.com'
});
async function run() {
await conn.dropDatabase();
await test.save();
mongoose.set('debug', true);
let doc = await Test.findOne({ 'email': { '$regex': 'lineus@gmail.com', '$options': 'i' } });
console.log(doc);
return conn.close();
}
run();
$: ./johncdf.js
Mongoose: tests.findOne({ email: { '$regex': 'lineus@gmail.com', '$options': 'i' } }, { fields: {} })
{ _id: 5b398396f9280606ebe5572a,
email: 'lineus@gmail.com',
__v: 0 }
$:
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.