This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongoose = require('./../mongoose'); | |
mongoose.connect('localhost', 'testing_596'); | |
function validatePresenceOf (value) { | |
console.error('validating ', value); | |
if (value === null) return false; | |
return value; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongoose = require('mongoose'); | |
mongoose.connect('localhost', 'testing_645'); | |
var schema = new mongoose.Schema({ | |
dtStart: Date | |
}); | |
var Org = new mongoose.Schema({ events: [schema] }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongoose = require('mongoose'); | |
mongoose.connect('localhost', 'test'); | |
mongoose.set('debug', true) | |
var Foo = new mongoose.Schema({ | |
name: { type: String | |
, index: { unique: true, background: true } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo deleting branch $1 | |
git push origin :$1 | |
git branch -D $1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongoose = require('mongoose') | |
, Schema = mongoose.Schema | |
, db = mongoose.connect('localhost', 'testing_streaming').connection | |
, Stream = require('stream').Stream | |
, express = require('express') | |
/** | |
* Dummy schema. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// today | |
Thing.find({ name: {$in: someNames }}).each(function (err, doc, next) { | |
if (err) return done(err); | |
if (!doc) return done(); | |
doSomethingAsync(doc, function (err) { | |
if (err) return done(err); | |
// we are handling iteration manually by using `next` | |
next(); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongoose = require('./mongoose'); | |
var Schema = mongoose.Schema; | |
mongoose.connect('localhost', 'testing_604'); | |
// original git://gist.github.com/1352079.git | |
var CalendarEvent = new Schema({ | |
title : String, | |
allDay : Boolean, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongoose = require('./mongoose'); | |
mongoose.connect('localhost', 'testing_585'); | |
var child = { name: String }; | |
var Child = new mongoose.Schema(child); | |
var Par = new mongoose.Schema({ child: child }); | |
var P = mongoose.model('Par', Par); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// pre hook | |
var emailAuthor = function( done ){ | |
console.log( '\nemailing author!\n' ); | |
done(); | |
}; | |
BlogPost.pre( 'save', function( next ){ | |
//next( new Error('something went wrong') ); | |
next(); | |
}); | |
BlogPost.pre( 'save', true, function( next, done ){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongoose = require('./mongoose'); | |
mongoose.connect('localhost', 'testing_546'); | |
var ObjectID = mongoose.Types.ObjectId; | |
var User = new mongoose.Schema({ | |
nickname : { type: String, index: true, unique: true } | |
, _avatar : { type: mongoose.Schema.ObjectId, ref: 'Avatar' } | |
}); |