33var mongoose = require ( 'mongoose' ) ,
44 Thing = mongoose . model ( 'Thing' ) ;
55
6- // Create all of the dummy things if Thing is empty
7- Thing . find ( function ( err , things ) {
8- if ( things . length === 0 ) {
9- console . log ( 'populating database' ) ;
10- Thing . create (
11- { name : 'HTML5 Boilerplate' , awesomeness : 10 } ,
12- { name : 'AngularJS' , awesomeness : 10 } ,
13- { name : 'Karma' , awesomeness : 10 } ,
14- { name : 'Express' , awesomeness : 10 } ,
15- { name : 'Mongoose' , awesomeness : 10 } , function ( err ) {
16- console . log ( 'finished populating' ) ;
17- }
18- ) ;
19- }
20- } ) ;
6+ //Clear old things, then add things in
7+ Thing . find ( { } ) . remove ( function ( ) {
8+ Thing . create ( {
9+ name : 'HTML5 Boilerplate' ,
10+ info : 'HTML5 Boilerplate is a professional front-end template for building fast, robust, and adaptable web apps or sites.' ,
11+ awesomeness : 10
12+ } , {
13+ name : 'AngularJS' ,
14+ info : 'AngularJS is a toolset for building the framework most suited to your application development.' ,
15+ awesomeness : 10
16+ } , {
17+ name : 'Karma' ,
18+ info : 'Spectacular Test Runner for JavaScript.' ,
19+ awesomeness : 10
20+ } , {
21+ name : 'Express' ,
22+ info : 'Flexible and minimalist web application framework for node.js.' ,
23+ awesomeness : 10
24+ } , {
25+ name : 'Mongoose' ,
26+ info : 'An excellent way to add validation and business logic to your mongoDB objects.' ,
27+ awesomeness : 10
28+ } , function ( err ) {
29+ console . log ( 'finished populating things' ) ;
30+ }
31+ ) ;
32+ } ) ;
0 commit comments