...
 
Commits (2)
//Require Mongoose
var mongoose = require('mongoose');
var PersonSchema = require('./person').schema
var DataObjectSchema = require('./dataObject').schema
//Define a schema
var Schema = mongoose.Schema;
......@@ -14,7 +15,8 @@ var ApplicationSchema = new Schema({
statusLastChangeDate : String,
decisionDate : String,
decisionJustification : String,
applicant : PersonSchema
applicant : PersonSchema,
dataObjects : [DataObjectSchema]
});
//Export function to create "Application" model class
......
//Require Mongoose
var mongoose = require('mongoose');
//Define a schema
var Schema = mongoose.Schema;
var DataObjectSchema = new Schema({
dataObjectId : String,
verfahrensId : String,
leikaId : String,
title : String,
type : String,
content : Schema.Types.Mixed
});
//Export function to create "DataObject" model class
module.exports = DataObject = mongoose.model('DataObject', DataObjectSchema );
\ No newline at end of file
......@@ -9,7 +9,12 @@ const Application = require('../models/application');
**/
exports.postCaseApplication = function(body) {
return new Promise(function(resolve, reject) {
const applicationRecord = Application.create(body);
// TODO maybe remove VerfahrensId later (discuss with Peter)
var applicationRecord = Application.create(body).then(function(doc) {
doc.verfahrensId = doc.id
doc.save()
return doc
});
resolve(applicationRecord);
});
}
......