用方括号括起来的Javascript成员变量

时间:2017-02-02 05:54:10

标签: javascript arrays node.js mongodb mongoose

我正在尝试调试Node.JS和Mongoose的问题,而不是正确保存数据。我有一个包含多个嵌套对象和对象数组的大对象。我在保存之前就在Chrome的devtools和Node devtools中查看它。它只有几个具有此问题的嵌套对象。对象数组中的成员变量用方括号[]括起来。我在保存前查看Node devtools中的数据时发现了这一点。

0: Object
    [attributeName]: "Grow raccoon tail"
    [componentId]: "58918f2c6f92704b0868aa30"
    [derivativeName]: ""
    [entityId]: "58918f9d6f92704b0868aa3e"
    [isStateVariable]: "false"
    [name]: "Feather"
    [parentId]: "0"
    [startValue]: "0"
    [variableName]: "tail"

以下是问题对象的架构

var componentVariableSchema = mongoose.Schema({
    componentId: { type: ObjectId },
    entityId: { type: ObjectId },
    name: String,
    attributeName: String,
    isStateVariable: { type: Boolean, default: false },
    variableName: String,
    derivativeName: String,
    startValue: { type: Number, default: 0.0 }
},
{
    timestamps: true
});

这是父对象的架构

var simulationSchema = mongoose.Schema({
    createdDate: { type: Date, default: Date.now },
    modifiedDate: { type: Date, default: Date.now },
    name: { type: String, default: Date.now },
    description: { type: String },
    parentId: { type: ObjectId, ref: 'Project' },

    // Variables
    componentVariables: [componentVariableSchema],
    simulationVariables: [simulationVariableSchema],

    // Integrator
    integratorType: { type: String },
    integratorParams: [Number],

    // Conditions
    startTime: 0,
    stopTime: 0,
    initialValues: [Number],

    // Containers for the code portion of the simulation
    initializationCode: { type: String },
    preFireCommandCode: { type: String },
    staveVariableDerivativesCode: { type: String },
    postFireCommandCode: { type: String },

    // A simulation can be run multiple times with different sets of results
    resultsList: [simulationResultSchema],

    createdByUserId: { type: ObjectId, ref: 'User' },
    isViewableToOthers: Boolean,

    deletedBy: { type: ObjectId },
    deletedDate: { type: Date }
},
{
    timestamps: true
});

simulationVariables数组具有相同的问题。父对象simulationSchema位于其父对象的数组中,但所有成员变量看起来都是正确的。我以前从未见过这个,我无法弄清楚是什么导致它。

0 个答案:

没有答案
相关问题