- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
假设我有一个这样的产品系列:
{
"_id": "5a74784a8145fa1368905373",
"name": "This is my first product",
"description": "This is the description of my first product",
"category": "34/73/80",
"condition": "New",
"images": [
{
"length": 1000,
"width": 1000,
"src": "products/images/firstproduct_image1.jpg"
},
...
],
"attributes": [
{
"name": "Material",
"value": "Synthetic"
},
...
],
"variation": {
"attributes": [
{
"name": "Color",
"values": ["Black", "White"]
},
{
"name": "Size",
"values": ["S", "M", "L"]
}
]
}
}
和像这样的变体集合:
{
"_id": "5a748766f5eef50e10bc98a8",
"name": "color:black,size:s",
"productID": "5a74784a8145fa1368905373",
"condition": "New",
"price": 1000,
"sale": null,
"image": [
{
"length": 1000,
"width": 1000,
"src": "products/images/firstvariation_image1.jpg"
}
],
"attributes": [
{
"name": "Color",
"value": "Black"
},
{
"name": "Size",
"value": "S"
}
]
}
我想将文档分开,为了便于浏览、搜索和分面搜索实现,我想在单个查询中获取所有数据,但我不想在我的应用程序代码中加入。我知道使用名为 summary 的第三个集合是可以实现的,它可能看起来像这样:
{
"_id": "5a74875fa1368905373",
"name": "This is my first product",
"category": "34/73/80",
"condition": "New",
"price": 1000,
"sale": null,
"description": "This is the description of my first product",
"images": [
{
"length": 1000,
"width": 1000,
"src": "products/images/firstproduct_image1.jpg"
},
...
],
"attributes": [
{
"name": "Material",
"value": "Synthetic"
},
...
],
"variations": [
{
"condition": "New",
"price": 1000,
"sale": null,
"image": [
{
"length": 1000,
"width": 1000,
"src": "products/images/firstvariation_image.jpg"
}
],
"attributes": [
"color=black",
"size=s"
]
},
...
]
}
问题是,我不知道如何使摘要集合与产品和变体集合保持同步。我知道可以使用 mongo-connector 来完成,但我不确定如何实现它。请帮助我,我还是一个初学者。
最佳答案
您实际上不需要维护摘要集合,将产品和变体摘要存储在另一个集合中是多余的
您可以使用聚合管道 $lookup 而不是使用 productID 外部连接产品和变体
聚合管道
db.products.aggregate(
[
{
$lookup : {
from : "variation",
localField : "_id",
foreignField : "productID",
as : "variations"
}
}
]
).pretty()
关于node.js - MongoDB 创建产品摘要集合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48601922/
我最近发布了一个 problem我正在进行身份验证,但没有收到任何回复,所以我想到了另一种方式来提问而不是多余的。 我在应用程序中看到的内容 documentation是传递访问 token 以进行身
我有一个具有许多不同值的因素。如果执行 summary(factor)输出是不同值及其频率的列表。像这样: A B C D 3 3 1 5 我想制作频率值的直方图,即 X 轴包含发生的不同频率,Y 轴
我有 2 个表,其中包含一组数据,如下所示,我想获得 RESULT 中的结果,该结果将在字段 balance 中进行计算: 我被困在余额字段中,如何让余额运行? tblIn in_date |
我有一个大量重载的方法 MethodA,它由我的 MethodB 文档中的摘要标记引用: /// A link to void MethodB { ... } 注释不应仅依赖于 MethodA 的特
当我将新的 details 标签与 summary 结合使用时,我想禁用生成的输入。我以为 可以解决这个问题,但遗憾的是它不起作用。 如何禁用细节元素? 最佳答案 一个非常简单的方法是只使用 CSS
如何在 Visual Studio 中生成此类摘要? /// /// Returns a number /// /// /// 最佳答案 在你的方法、属性等之前输入///,VS会自动生成注释
关于简单的看似无辜的函数的简单问题:summary。 直到我看到min和max的结果超出了我的数据范围,我才意识到summary有一个指定输出结果精度的参数。我的问题是如何以一种干净、普遍的方式来解决
我有一个数据框 a,其中包含 4 个标识列:A、B、C、D。使用 ddply() 创建的第二个数据框 b 包含每组 的不同 D 的所有值的摘要>A、B、C。第三个数据框 c 包含 b 的子集,其中包含
这个问题在这里已经有了答案: jsdoc: multiline description @property (4 个回答) 4年前关闭。 我正在为我的 javascript 项目使用 Visual S
我有一个向量的 R 摘要: summary(vector) Min. 1st Qu. Median Mean 3rd Qu. Max. 1.000 1.000 2.000 6
我想创建一个新的计算列(另一列文本的摘要)。为了让您重现,我创建了一个 df 作为可重现的示例: df head(df,3) name 1 ZKBOZVFKNJBRSDW
假设我有一棵对象树,其中每个对象都有一个字符串表示。我想在整棵树上创建一个 SHA1 摘要。 最简单的方法是递归遍历树的每个节点。对于每个节点,我将连接(作为简单字符串)所有子节点的 SHA1 摘要,
因此,我试图围绕 MVVM 进行思考,但我发现我的问题多于答案。当涉及到下一步时,这些教程对我来说还远远不够...... 基本上我想要一个项目列表,然后是一种获取每个项目详细信息的方法。 下面是我在网
我希望将 princomp PCA(必须是 princomp)的摘要作为数据框,以便我可以使用 kable 格式化表格以生成报告。 这是我尝试使用的代码,从中应该清楚我想要做什么; kable( as
我们的一页很重。为了减少我们的观察者数量并加速 Angular 摘要周期,我们大量使用了 On-Time-Binding 语法 :: .我们也在使用angular-bind-notifier以避免对我
我正在与我受雇的公司合作,试图为我们的内部库创建更好的文档。我们希望最终检查每个类并更新我们的命名方案(过去有很多草率的代码)。我想要的是能够打印出 javadoc 的摘要。它需要排除页面底部的完整解
我正在尝试创建一个分组摘要,报告每个组中的记录数,然后还显示一系列变量的均值。 我只能弄清楚如何将其作为两个单独的摘要进行处理,然后再将它们合并在一起。这工作正常,但我想知道是否有更优雅的方法来做到这
我正在尝试从 this file 中获取带有百分比的交叉表使用 Hmisc .但为什么是summary()从变量 OCCUPATION 中删除类别(“OTHERS”)? library(Hmisc)
已结束。此问题正在寻求书籍、工具、软件库等的推荐。它不满足Stack Overflow guidelines 。目前不接受答案。 我们不允许提出寻求书籍、工具、软件库等推荐的问题。您可以编辑问题,以便
如标题所示,我想为 PreferenceAcitvity 创建自定义标题栏。我需要在标题下方添加摘要。目前它只会显示一个标题,但我需要一个副标题,就像任何 Preference 都可以有一个摘要。 我
我是一名优秀的程序员,十分优秀!