【发布时间】:2016-03-19 15:08:13
【问题描述】:
我创建了一个 NodeJS 项目来记录 MongoDB 中的 JSON 对象,该对象曾经出现在我的 JAVA API 中。为了插入对象,我定义了 JSON 模式并将其设置为 Mongoose 对象,如下所示。
var stateModel = require('./model/TeslaProfileRequest_JSONSchema.json');
var stateSchema = new mongoose.Schema(stateModel);
var State = mongoose.model('TeslaRequest', stateSchema);
这样,我可以保存我的 JSON 对象,但它是紧密耦合的过程。因为如果我的 Java API 中更改了 TeslaProfileRequest_JSONSchema.json,我也必须更改 Node JS 项目中的 JSON 模式。
我想要做的是,在我的 Node JS 项目中不定义 JSON 模式,我想记录这个 API 接收到的对象。请帮帮我。
【问题讨论】:
标签: java json node.js mongodb mongoose