tellform/app/models/logic_jump.server.model.js

82 lines
1.2 KiB
JavaScript
Raw Normal View History

2015-09-03 18:21:56 +00:00
'use strict';
/**
* Module dependencies.
*/
var mongoose = require('mongoose'),
Schema = mongoose.Schema,
_ = require('lodash'),
2016-08-23 21:45:59 +00:00
math = require('mathjs');
2015-09-03 18:21:56 +00:00
2016-08-23 21:45:59 +00:00
var schemaOptions = {
toObject: {
virtuals: true
},
toJSON: {
virtuals: true
2015-11-23 21:06:02 +00:00
}
2015-09-10 22:06:28 +00:00
};
2015-09-03 18:21:56 +00:00
var LogicJumpSchema = new Schema({
2016-08-23 21:45:59 +00:00
expressionString: {
type: String,
enum: [
'field == static',
'field != static',
'field > static',
'field >= static',
'field <= static',
'field < static',
'field contains static',
'field !contains static',
'field begins static',
'field !begins static',
'field ends static',
2016-11-14 19:10:51 +00:00
'field !ends static'
2016-08-23 21:45:59 +00:00
]
2015-09-03 18:21:56 +00:00
},
2016-08-23 21:45:59 +00:00
fieldA: {
2015-09-03 18:21:56 +00:00
type: Schema.Types.ObjectId,
2016-08-23 21:45:59 +00:00
ref: 'FormField'
},
valueB: {
type: Schema.Types.String
2015-09-03 18:21:56 +00:00
},
2016-08-23 21:45:59 +00:00
jumpTo: {
type: Schema.Types.ObjectId,
ref: 'FormField'
}
}, schemaOptions);
/*
IS EQUAL TO statement
var scope = {
a: val1,
b: val2
};
math.eval('a == b', scope);
IS NOT EQUAL TO statement
var scope = {
a: val1,
b: val2
};
math.eval('a !== b', scope);
BEGINS WITH statement
ENDS WITH statement
2015-09-03 18:21:56 +00:00
2016-08-23 21:45:59 +00:00
CONTAINS statement
DOES NOT CONTAIN statement
*/
2015-09-03 18:21:56 +00:00
mongoose.model('LogicJump', LogicJumpSchema);
2016-08-23 21:45:59 +00:00
module.exports = LogicJumpSchema;