let mongoose = require('mongoose');

let oprSchema = mongoose.Schema({
        operateDate: String,
        operator: String
    },
    {_id: false},
    {versionKey: false});

let stdBillsLibSchema =mongoose.Schema({
        creator: String,
        createDate: String,
        recentOpr: [oprSchema],
        /* lastOperator: String,
         lastOperateDate: Date,*/
        billsLibId: Number,
        billsLibName: String,
        compilationId: String,
        compilationName: String,
        deleted: Boolean
    },
    {versionKey: false}
);

let jobsSchema = mongoose.Schema({
        id: Number,
        serialNo: Number
    },
    {_id: false},
    {versionKey: false});

let itemsSchema = mongoose.Schema({
        id: Number,
        serialNo: Number
    },
    {_id: false},
    {versionKey: false});

let billsSchema = mongoose.Schema({
        ID: Number,
        ParentID: Number,
        NextSiblingID: Number,
        code: String,
        name: String,
        unit: String,
        ruleText: String,
        Expression: String,
        jobs: [],
        items: [],
        recharge:String,
        billsLibId: Number,
        deleted: Boolean
    },
    {versionKey: false}
);

let jobContentSchema = mongoose.Schema({
        id: Number,
        code: Number,
        content: String,
        billsLibId: Number,
        deleted: Boolean
    },
    {versionKey: false}
);

let itemCharacterSchema = mongoose.Schema({
        id: Number,
        code: Number,
        content: String,
        itemValue: Array,
        billsLibId: Number,
        deleted: Boolean
    },
    {versionKey: false}
);

module.exports = {
    stdBillsLibSchema: stdBillsLibSchema,
    billsSchema: billsSchema,
    jobContentSchema: jobContentSchema,
    itemCharacterSchema: itemCharacterSchema
}