On Tuesday, 10 October 2017 at 09:43:10 UTC, Anders S wrote:
Hi,

I'm working on a middleware application that reads array of data from a POSIX pipe and insert data into the db if any position in the array has changed. This is where my problem lays, in order not to duplicate data I want to fetch the latest data/document in the array of documents.
I'm using MS Code and dub to code and compile.

This is the code:
Collection ct = mongo.boxweb.celltab;
int i = 1;
for(;i < 10; i++ ){
auto cell = ct.find({"number":i}).sort({_id:-1}).limit(2).pretty(); if (<data from pipe[i].pos1 == cell.pos1) then do some insert...

   i++;
....
Where "number" is the document nr in the array

I get these errors
source/app.d(166,54): Error: found : when expecting ; following statement source/app.d(166,56): Error: found } when expecting ; following statement
source/app.d(166,57): Error: found ) instead of statement
dmd failed with exit code 1.

Any ideas?
Isn't there a way to markup code in the forum message to separate from the bodytext?

/anders


Hello,

I haven't used mongo and D together, but by looking at [0] and [1] I can see that mondo is using Bson, which, as far as I can tell takes an associative array.

I'm guessing you need to replace the JS dictionary sintax { k: v } with the AA one [ k: v ].

I haven't been able to try this out as I am on my phone. Also, this might be more suited for the Learn thread.

Regarding the code markup, as far as I know, we don't have this.

Hope this helps,
Eduard

[0] - https://code.dlang.org/packages/mondo
[1] - http://vibed.org/api/vibe.data.bson/

Reply via email to