'use strict'; const Schema = require('mongoose').Schema; const moment = require('moment'); const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin'); const { ObjectId } = require('mongoose').Types; // 集群节点表 const qnodes = { node: { type: String }, state: { type: String }, power_state: { type: String }, np: { type: String }, ntype: { type: String }, jobs: { type: String }, status: { type: String }, macaddr: { type: String }, cpuclock: { type: String }, varattr: { type: String }, energy_used: { type: String }, mem: { type: String }, vmem: { type: String }, walltime: { type: String }, session_id: { type: String }, size: { type: String }, netload: { type: String }, gres: { type: String }, loadave: { type: String }, ncpus: { type: String }, physmem: { type: String }, availmem: { type: String }, totmem: { type: String }, idletime: { type: String }, nusers: { type: String }, nsessions: { type: String }, sessions: { type: String }, uname: { type: String }, opsys: { type: String }, mom_service_port: { type: String }, mom_manager_port: { type: String }, time: { type: String }, remark: { type: String, maxLength: 200 }, create_time: { type: String, default: moment(new Date()).format('YYYY-MM-DD HH:mm:ss') }, }; const schema = new Schema(qnodes, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.index({ time: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Qnodes', schema, 'qnodes'); };