Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //////////////////////// entryModel.js ////////////////////////
- 'use strict';
- var options = {},
- config = require('../../config'),
- mongoose = require('mongoose');
- // Merge options with defaults
- const driverOptions = Object.assign(config.defaultOptions, options);
- // Use Promise from options (mongoose)
- mongoose.Promise = driverOptions.promiseLibrary;
- // Connect
- var node = mongoose.createConnection(config.dbPath, driverOptions);
- var Schema = mongoose.Schema;
- var EntrySchema = new Schema({
- entryID: Schema.Types.ObjectId,
- userID: {
- type: Number,
- Required: true
- },
- entryDate: {
- type: Date,
- Required: true
- },
- entryType: {
- type: String,
- Required: true
- },
- mainText: String,
- descText: String,
- eventDate: String,
- mediaUrl: String
- });
- module.exports = node.model('entry', EntrySchema);
- ////////////////////////////// entryController.js //////////////////////////////////////////////
- var options = {},
- config = require('../../config'),
- mongoose = require('mongoose');
- // Merge options with defaults
- const driverOptions = Object.assign(config.defaultOptions, options);
- // Use Promise from options (mongoose)
- mongoose.Promise = driverOptions.promiseLibrary;
- // Connect
- var node = mongoose.createConnection(config.dbPath, driverOptions);
- var Entry = node.model("entrys");
- exports.getUserEntries = function(req, res) {
- //Find all entries where the entry's userID matches the 'userID' passed
- Entry.find({ userID: req.params.userID }, function(err, entry){
- if (err)
- res.send(err);
- res.json(entry);
- });
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement