-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDb.js
executable file
·37 lines (30 loc) · 893 Bytes
/
Db.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var express = require('express');
var http = require('http');
var path = require('path');
var config = require('nodejs-config');
var Product = require('./models/product').Product;
var mongoose = require('mongoose');
mongoose.connect('mongodb://127.0.0.1:27017/promsnabdbadmin');
Product.insert = function (title, description, category, price, show, meta) {
var product = new Product({
title: title,
description: description,
category: category,
price: price,
show: show,
meta: meta
});
product.save(function (err) {
if (err) throw err;
Product.find(function (err, product) {
console.log(product);
});
});
};
Product.findToTitle = function (title) {
Product.find({title:title}, function (err, product) {
if (err) throw err;
Product.item = product;
})
};
module.exports = Product;