/**
 * Created by CSL on 2017-10-22.
 */
let mongoose = require('mongoose');
let Schema = mongoose.Schema;

let calcItemSchema = new Schema({
    ID: Number,
    code: String,
    name: String,
    fieldName: String,
    dispExpr: String,
    dispExprUser: String,
    expression: String,
    compiledExpr: String,
    statement: String,
    feeRateID: Number,
    feeRate: String,
    labourCoeID: Number,
    memo: String,
    custom: Boolean
},{versionKey:false, _id: false});

let templateSchema = new Schema({
    ID: Number,
    name: String,
    calcItems: [calcItemSchema],
    custom: Boolean
},{versionKey:false, _id: false});


let projectCalcPrograms = new Schema({
    ID: String,
    projectID: Number,
    name: String,
    libID: Number,
    libName: String,
    templates: [templateSchema]
},{versionKey:false});

mongoose.model('calc_programs', projectCalcPrograms, 'calc_programs');