English 中文(简体)
Mongodb确保阵列和单项计票的正确性
原标题:Mongodb ensure the correctness of array and count in single query

{ id = "castle",
tags = [ "Red", "Black", "White" ], count:3 }

我的收集像上文一样,是一个具有独特项目和阵列的标记阵列。

I would like to add a tags and increment the tags count in a single query.

var query = Query.EQ("id", "castle");
var update = Update.AddToSetWrapped("tags", "White").Inc(count", 1); Photo.Update(query, update);

我预计,由于“白白”已经处于tag阵列中,因此不执行 $费,因此,这一询问的第一部分是无效的。

但实际结果为斜体字塔插入(更正),反面则得到增减(定点!)。

我想知道,我是否能够在上述个案中单挑出。

我正在使用中途C#司机。

最佳回答

这实际上限制了孟买。 没有任何“触发”或“更新x,如果<代码>addToSet工程”。

https://jira.mongodb.org/browse/SERVER-786“rel=“nofollow”>here。 https://jira.mongodb.org/browse/SERVER-2769“rel=“nofollow”>。 如果你想要这样做,就不得不对他们进行投票。 当然,第一个国家已经开放了一年多的时间,而且没有安排,因此目前并不认为这一点很重要。

问题回答

Given MongoDB limitations, you can query records with id="castle" that don t have a "White" tag. Then run the update only if you get any records.





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签