Skip to content

Commit ab444fc

Browse files
author
frankafan
committed
Attempt iterator in backend.
1 parent 487a2ae commit ab444fc

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

models/siteInfo.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
var mongoose = require('mongoose');
2+
3+
4+
var db = mongoose.connection
5+
var siteInfoSchema = new mongoose.Schema({visitors: Number, type: String}, { strict: false });
6+
7+
8+
// db.once('open', function() {
9+
// console.log("Connection Successful!");
10+
11+
// // define Schema
12+
// var siteInfoSchema = new mongoose.Schema({visitors: Number, type: String}, { strict: false });
13+
// // compile schema to model
14+
// var siteInfo = mongoose.model('siteInfo', siteInfoSchema, 'siteInfo');
15+
16+
// // a document instance
17+
// var siteInfo1 = new siteInfo({ visitors: 0, type: 'visitor_count' });
18+
19+
// // save model to database
20+
// siteInfo1.save(function (err, siteinfo) {
21+
// if (err) return console.error(err);
22+
// });
23+
24+
// });
25+
26+
module.exports = mongoose.model('SiteInfo', siteInfoSchema);

routes/show.js

+2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ const router = express.Router();
44
const fs = require("fs");
55
const helper = require("../routes/helpers/helpers");
66
const DataLibrary = require("../models/datalibrary");
7+
const SiteInfo = require("../models/siteinfo");
78

89
router.get("/:type/:uniquestudyid", function (req, res, next) {
10+
// SiteInfo.findOneAndUpdate({type :'visitor_count'}, {$inc : {'visitors' : 1}}).exec();
911
var home = "lab_exp";
1012
if (process.env.NODE_ENV == "production") {
1113
home = "app";

0 commit comments

Comments
 (0)