下面是我的mongpdb json文档
{
categoryId: '1',
categoryName: 'Outdoors Equipments',
items: [
{
itemId: '1',
itemName: 'Camping Tent',
itemDescription: 'A tent is a shelter consisting of sheets of fabric or other material draped over, attached to a frame of poles or attached to a supporting rope. While smaller tents may be free-standing or attached to the ground, large tents are usually anchored using guy ropes tied to stakes or tent pegs. First used as portable homes by nomads, tents are now more often used for recreational camping and as temporary shelters.',
itemImage: '/images/camping-tent.jpeg',
createdAt: DateTime.now().toLocaleString(DateTime.DATETIME_SHORT)
},
{
itemId: '2',
itemName: 'Camping Chair',
itemDescription: 'A tent is a shelter consisting of sheets of fabric or other material draped over, attached to a frame of poles or attached to a supporting rope. While smaller tents may be free-standing or attached to the ground, large tents are usually anchored using guy ropes tied to stakes or tent pegs. First used as portable homes by nomads, tents are now more often used for recreational camping and as temporary shelters.',
itemImage: '/images/camping-chair.jpeg',
createdAt: DateTime.now().toLocaleString(DateTime.DATETIME_SHORT)
},
{
itemId: '3',
itemName: 'Camping Table',
itemDescription: 'A tent is a shelter consisting of sheets of fabric or other material draped over, attached to a frame of poles or attached to a supporting rope. While smaller tents may be free-standing or attached to the ground, large tents are usually anchored using guy ropes tied to stakes or tent pegs. First used as portable homes by nomads, tents are now more often used for recreational camping and as temporary shelters.',
itemImage: '/images/camping-table.jpeg',
createdAt: DateTime.now().toLocaleString(DateTime.DATETIME_SHORT)
},
]
}如何基于类别和itemid进行搜索,并使用mongoose和nodejs express返回包含特定项的类别数据和项数据的json。
发布于 2022-04-02 06:28:43
您可以将$elemMatch和$ operator用于此$elemMatch文档 $操作员文件
https://stackoverflow.com/questions/71715277
复制相似问题