【发布时间】:2018-07-16 17:24:53
【问题描述】:
我正在尝试在我拥有的一个字段中发送一个 JSON 对象,以便将其存储在 MongoDB 中(使用 Mongoose 模式)。现在我面临一个服务器端的 JSON 解析错误。
这就是我要发送的内容
{
"text":"N1y",
"localId":"123",
"type": "media",
"attachments": {
url:"Test.jpg",
publicId:"123"
}
}
我的 Moongose 架构
const messageSchema = mongoose.Schema({
createdAt: {
type: String,
default: new Date()
},
chatId: {
type: String,
required: true
},
localId: {
type: String,
required: true
},
text: {
type: String,
required: true
},
authorId: {
type: String,
required: true
},
type: {
type: String,
default: 'text'
},
attachments: {},
style: {
type: String,
default: 'normal'
}
将 Node.JS 与 Express 结合使用。
【问题讨论】:
标签: node.js mongodb rest express