Skip to content

Instantly share code, notes, and snippets.

var mongoose = require('./../mongoose');
mongoose.connect('localhost', 'testing_596');
function validatePresenceOf (value) {
console.error('validating ', value);
if (value === null) return false;
return value;
};
var mongoose = require('mongoose');
mongoose.connect('localhost', 'testing_645');
var schema = new mongoose.Schema({
dtStart: Date
});
var Org = new mongoose.Schema({ events: [schema] });
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 }
}
#!/bin/bash
echo deleting branch $1
git push origin :$1
git branch -D $1
var mongoose = require('mongoose')
, Schema = mongoose.Schema
, db = mongoose.connect('localhost', 'testing_streaming').connection
, Stream = require('stream').Stream
, express = require('express')
/**
* Dummy schema.
*/
// 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();
});
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,
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);
// 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 ){
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' }
});