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; | |
var db = mongoose.connect('mongodb://localhost/test'); | |
var TestEmbedSchema = new Schema({ | |
name : { type: String, index: true} | |
}); | |
var TestEmbed = mongoose.model('TestEmbed', TestEmbedSchema); |
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 ; | |
var PageSchema = new Schema({ | |
author: { | |
first_name: String | |
, last_name: 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
// 'test pushing simple embedded documents into a document' | |
var mongoose = require('mongoose') | |
, should = require('should') | |
, Schema = mongoose.Schema; | |
mongoose.connect('mongodb://localhost/test'); | |
var EmbeddedSchema = new Schema({ | |
title : 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') | |
, Schema = mongoose.Schema ; | |
mongoose.connect('mongodb://localhost/test'); | |
var ContactNameSchema = new Schema({ | |
familyName: String, | |
givenName: 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') | |
, Schema = mongoose.Schema | |
, ObjectId = mongoose.SchemaTypes.ObjectId | |
, should = require('should'); | |
mongoose.connect('mongodb://localhost/test'); | |
var CommentSchema = new Schema({ | |
id : ObjectId, | |
user : 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') | |
, Schema = mongoose.Schema ; | |
mongoose.connect('mongodb://localhost/test'); | |
var EmbeddedDocSchema = new Schema({ | |
date: Date | |
, name: 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') | |
, Schema = mongoose.Schema ; | |
mongoose.connect('mongodb://localhost/test'); | |
var NewsModelSchema = new Schema({ | |
name: String | |
, title: 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') | |
mongoose.connect('mongodb://localhost/sebtest'); | |
var Schema = mongoose.Schema; | |
var StackItemSchema = new Schema({ | |
blob: Number | |
}); | |
var StackSchema = new 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 assert = require('assert'), | |
express = require('express'), | |
gzip = require('connect-gzip'); | |
var app = express.createServer(); | |
app.set('view engine', 'jade'); | |
app.use(gzip.gzip()); | |
app.use(express.bodyParser()); |
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
findOrCreateUser: function (sess, accessTok, accessTokExtra, fbUser) { | |
var promise = this.Promise() | |
, User = this.User()(); | |
if(sess.auth == null || sess.auth.userId == null) { | |
User.findOne({'fb.id': fbUser.id}, function (err, foundUser) { | |
if (foundUser) { | |
if( foundUser.confirmed ) { | |
return promise.fulfill(foundUser); | |
} else { | |
assignFbDataToUser(foundUser, accessTok, accessTokExtra, fbUser); |