From 1b89c2382e8c006a6639cf99b84a3ecc26cf0526 Mon Sep 17 00:00:00 2001 From: Sean Sundberg Date: Wed, 17 May 2017 00:00:31 -0500 Subject: [PATCH] Updated db definition in initdb.js and added createtestdata.js --- db/createtestdata.js | 76 ++++++++++++++++++++++++++++++++++++++++++++ db/initdb.js | 6 ++-- 2 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 db/createtestdata.js diff --git a/db/createtestdata.js b/db/createtestdata.js new file mode 100644 index 0000000..0c634f2 --- /dev/null +++ b/db/createtestdata.js @@ -0,0 +1,76 @@ +var db = connect('127.0.0.1:27017/peoplecount'); + +db.countcapture.insert({ + _id: 1, + captureDate: new Date(), + totalCount: 100, + deviceCount: 2 +}); + +db.countcapturedevice.insert({ + countcapture_id: 1, + deviceId: 'mini1', + count: 50 +}); +db.countcapturedevice.insert({ + countcapture_id: 1, + deviceId: 'mini2', + count: 50 +}); + + +db.countcapture.insert({ + _id: 2, + captureDate: new Date(), + totalCount: 150, + deviceCount: 3 +}); + +db.countcapturedevice.insert({ + countcapture_id: 2, + deviceId: 'mini1', + count: 50 +}); +db.countcapturedevice.insert({ + countcapture_id: 2, + deviceId: 'mini2', + count: 50 +}); +db.countcapturedevice.insert({ + countcapture_id: 2, + deviceId: 'mini3', + count: 50 +}); + + +db.countcapture.insert({ + _id: 3, + captureDate: new Date(), + totalCount: 90, + deviceCount: 1 +}); + +db.countcapturedevice.insert({ + countcapture_id: 3, + deviceId: 'mini1', + count: 90 +}); + + +db.countcapture.insert({ + _id: 4, + captureDate: new Date(), + totalCount: 125, + deviceCount: 3 +}); + +db.countcapturedevice.insert({ + countcapture_id: 4, + deviceId: 'mini1', + count: 75 +}); +db.countcapturedevice.insert({ + countcapture_id: 4, + deviceId: 'mini2', + count: 50 +}); diff --git a/db/initdb.js b/db/initdb.js index a702651..1773883 100644 --- a/db/initdb.js +++ b/db/initdb.js @@ -1,8 +1,8 @@ var db = connect('127.0.0.1:27017/peoplecount'); - +db.countcapture.drop(); db.createCollection('countcapture'); -db.countcapture.createIndex({captureId: 1}, {unique: true}); +db.countcapturedevice.drop(); db.createCollection('countcapturedevice'); -db.countcapturedevice.createIndex({captureId: 1, deviceId: 1}, {unique: true}); \ No newline at end of file +db.countcapturedevice.createIndex({countcapture_id: 1, deviceId: 1}, {unique: true}); \ No newline at end of file