mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-13 11:12:47 +00:00
updated bunch of file paths and changed the way posts are loaded
This commit is contained in:
28
node_modules/mongoose/examples/population/population-across-three-collections.js
generated
vendored
28
node_modules/mongoose/examples/population/population-across-three-collections.js
generated
vendored
@@ -1,5 +1,5 @@
|
||||
|
||||
var assert = require('assert')
|
||||
var assert = require('assert');
|
||||
var mongoose = require('../../lib');
|
||||
var Schema = mongoose.Schema;
|
||||
var ObjectId = mongoose.Types.ObjectId;
|
||||
@@ -8,7 +8,7 @@ var ObjectId = mongoose.Types.ObjectId;
|
||||
* Connect to the db
|
||||
*/
|
||||
|
||||
var dbname = 'testing_populateAdInfinitum_' + require('../../lib/utils').random()
|
||||
var dbname = 'testing_populateAdInfinitum_' + require('../../lib/utils').random();
|
||||
mongoose.connect('localhost', dbname);
|
||||
mongoose.connection.on('error', function() {
|
||||
console.error('connection error', arguments);
|
||||
@@ -34,7 +34,7 @@ var blogpost = Schema({
|
||||
type: Schema.ObjectId,
|
||||
ref: 'User'
|
||||
}
|
||||
})
|
||||
});
|
||||
var BlogPost = mongoose.model('BlogPost', blogpost);
|
||||
|
||||
/**
|
||||
@@ -71,7 +71,7 @@ mongoose.connection.on('open', function() {
|
||||
friends: [userIds[0], userIds[1], userIds[2]]
|
||||
});
|
||||
|
||||
User.create(users, function(err, docs) {
|
||||
User.create(users, function(err) {
|
||||
assert.ifError(err);
|
||||
|
||||
var blogposts = [];
|
||||
@@ -79,19 +79,19 @@ mongoose.connection.on('open', function() {
|
||||
title: 'blog 1',
|
||||
tags: ['fun', 'cool'],
|
||||
author: userIds[3]
|
||||
})
|
||||
});
|
||||
blogposts.push({
|
||||
title: 'blog 2',
|
||||
tags: ['cool'],
|
||||
author: userIds[1]
|
||||
})
|
||||
});
|
||||
blogposts.push({
|
||||
title: 'blog 3',
|
||||
tags: ['fun', 'odd'],
|
||||
author: userIds[2]
|
||||
})
|
||||
});
|
||||
|
||||
BlogPost.create(blogposts, function(err, docs) {
|
||||
BlogPost.create(blogposts, function(err) {
|
||||
assert.ifError(err);
|
||||
|
||||
/**
|
||||
@@ -113,18 +113,18 @@ mongoose.connection.on('open', function() {
|
||||
path: 'author.friends',
|
||||
select: 'name',
|
||||
options: { limit: 2 }
|
||||
}
|
||||
};
|
||||
|
||||
BlogPost.populate(docs, opts, function(err, docs) {
|
||||
assert.ifError(err);
|
||||
console.log('populated');
|
||||
var s = require('util').inspect(docs, { depth: null })
|
||||
var s = require('util').inspect(docs, { depth: null });
|
||||
console.log(s);
|
||||
done();
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function done(err) {
|
||||
|
||||
Reference in New Issue
Block a user