MongoDB的 - 一个数组的最后一个元素上查询? [英] MongoDB - Query on the last element of an array?

查看:2635
本文介绍了MongoDB的 - 一个数组的最后一个元素上查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道MongoDB的支持语法 {找到array.0.field:值} ,但我特别想为数组中的最后一个元素做到这一点,这意味着我不知道索引。是否有某种运营商对于这一点,还是我的运气?

I know that MongoDB supports the syntax find{array.0.field:"value"}, but I specifically want to do this for the last element in the array, which means I don't know the index. Is there some kind of operator for this, or am I out of luck?

编辑:为了澄清,我想找到()只返回其中一个数组的最后一个元素一个字段匹配特定值的文件

To clarify, I want find() to only return documents where a field in the last element of an array matches a specific value.

推荐答案

我贴在官方蒙戈谷歌组的此处,并得到了他们的工作人员回答。看来,我正在寻找的,是不可能的。我将只使用一个不同的模式的方法。

I posted on the official Mongo Google group here, and got an answer from their staff. It appears that what I'm looking for isn't possible. I'm going to just use a different schema approach.

这篇关于MongoDB的 - 一个数组的最后一个元素上查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆