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
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_";' |
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_494'); | |
var Schema= mongoose.Schema; | |
function parseDate (v) { | |
return '2011-05-06'; | |
} |
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_487'); | |
var Schema = mongoose.Schema; | |
var db = mongoose.connection; | |
var S = new Schema({a: String, b: String}); |
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 | |
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); |
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 s = '4e527669644f786927000001' | |
var id = new mongoose.Types.ObjectId(s); | |
console.error(typeof id, id == s); // object, 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
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"; |
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; | |
var ObjectId = mongoose.Types.ObjectId; | |
console.error(mongoose.version); | |
var ResponseSchema = new Schema({}); | |
var AnswerSchema = new Schema({ | |
answer : String |
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
'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; |
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
'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) { |
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
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 |