Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
FranciZ committed Jul 16, 2015
0 parents commit ddc49f3
Show file tree
Hide file tree
Showing 2,069 changed files with 348,587 additions and 0 deletions.
24 changes: 24 additions & 0 deletions database.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
var mongoose = require('mongoose');

var db = mongoose.connection;

exports.openDatabase = function(cb){

mongoose.connect('mongodb://localhost/test');

db.on('error', console.error.bind(console, 'connection error:'));

db.once('open', function (callback) {

console.log('Connection to database open');
cb();

});

};

exports.getDatabase = function(){

return db;

};
11 changes: 11 additions & 0 deletions models/product.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
var mongoose = require('mongoose');

var productSchema = mongoose.Schema({
name : { type:String, unique:true },
price : Number,
stock : { type:Number },
available : { type:Boolean, default:false },
date : { type:Date, default:Date.now }
});

var Product = mongoose.model('Product', productSchema);
Loading

0 comments on commit ddc49f3

Please sign in to comment.