Skip to content

Instantly share code, notes, and snippets.

alias github='__git_branch_=$(git symbolic-ref -q HEAD);__git_branch_=${__git_branch_/#refs\/heads/};__git_repo_=$(git config --get remote.origin.url);__git_repo_=$ {__git_repo_/[email protected]:/};__git_repo_=${__git_repo_/%.git/};open "https://github.com/$__git_repo_/tree$__git_branch_";'
var mongoose = require('./mongoose');
mongoose.connect('localhost', 'testing_494');
var Schema= mongoose.Schema;
function parseDate (v) {
return '2011-05-06';
}
var mongoose = require('./mongoose')
mongoose.connect('localhost', 'testing_487');
var Schema = mongoose.Schema;
var db = mongoose.connection;
var S = new Schema({a: String, b: String});
var mongoose = require('mongoose')
var Schema = mongoose.Schema
console.error('mongoose version %s', mongoose.version);
var s = new Schema({ name: String })
s.pre('init', function (next, doc) {
console.error('pre', arguments);
var changed = { name: doc.first + ' ' + doc.last };
next(changed);
var mongoose = require('mongoose');
var s = '4e527669644f786927000001'
var id = new mongoose.Types.ObjectId(s);
console.error(typeof id, id == s); // object, true
global.hi = "Hello";
goodbye = "See ya";
global = Object.freeze(global);
console.error('global.hi: %s', hi);
console.error('global.goodbye: %s', goodbye);
hi = "Nice to see you";
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var ObjectId = mongoose.Types.ObjectId;
console.error(mongoose.version);
var ResponseSchema = new Schema({});
var AnswerSchema = new Schema({
answer : String
'pushing to an array of Mixed works': function () {
var db = start();
mongoose.model('MySchema_', new Schema({
arrays: []
}));
var DooDad = db.model('MySchema_')
, doodad = new DooDad({ arrays: [] })
, date = 1234567890;
'mixed fun': function () {
var db = start()
, Post = db.model('BlogPost', collection);
var post = new Post;
post.mixed = { x: { one: 1, two: 2 } };
post.markModified('mixed');
post.save(function (err) {
should.strictEqual(err, null);
Post.findById(post._id, function (err, post) {
a = 1;
console.error('global', typeof a); // undefined
const a; // const a is hoisted and set to undefined here first
a = 2; // has no affect
console.error('global after', typeof a); // still undefined