网上对于MongoDB内嵌数组操作这块的解说五花八门,其实结合Spring使用MongoTemplate操作,是非常方便的,闲话少叙上代码。
存入MongoDb中的数据格式:
{
"id": 1,
"storeIds": [1, 5, 10],
"content": "我是内容",
"type": 1,
"createTime": "2018-01-05 11:22:55"
"userIds": [
{
"userId": 100,
"readflag": true,
},
{
"userId": 200,
"readflag": false,
},
{
"userId": 300,
"readflag": true,
}
]
<