Hi,

I am trying to use the MongoDB driver, but I am having some issues. I have the following piece of code:

  auto logins = client.getCollection("logins.level2");
  auto user   = logins.find(["ip" : ip]);

  if (user.empty)
  {
    logins.insert(serializeToBson(
      [
        "ip"       : serializeToBson(ip),
        "attempts" : serializeToBson(1),
        "time"     : serializeToBson(to!int(Clock.currTime().toUnixTime()))
      ]
    ));
  }

This code is executed, when a user attempts to enter authenticated part of server. The data is successfully inserted into the DB (verified using the mongo client), but the user get this in the browser:

500 - Internal Server Error

Internal Server Error

Internal error information:
vibe.db.mongo.connection.MongoDriverException@../../.dub/packages/vibe-d-0.7.17/source/vibe/db/mongo/connection.d(302): BSON value is type 'Null', expected to be one of [Int]
----------------
/tmp/dub/4191021397/webserver(void vibe.db.mongo.connection.MongoConnection.checkForError(immutable(char)[])+0x84) [0x616e44]
/tmp/dub/4191021397/webserver(void vibe.db.mongo.connection.MongoConnection.insert(immutable(char)[], vibe.db.mongo.connection.InsertFlags, vibe.data.bson.Bson[])+0x251) [0x615881]
/tmp/dub/4191021397/webserver(void vibe.db.mongo.collection.MongoCollection.insert!(vibe.data.bson.Bson).insert(vibe.data.bson.Bson, vibe.db.mongo.connection.InsertFlags)+0x176) [0x61afae]
/tmp/dub/4191021397/webserver(void app.timedAuth(vibe.http.server.HTTPServerRequest, vibe.http.server.HTTPServerResponse)+0x24c) [0x576a9c]
/tmp/dub/4191021397/webserver(void std.functional.DelegateFaker!(void function(vibe.http.server.HTTPServerRequest, vibe.http.server.HTTPServerResponse)*).DelegateFaker.doIt(vibe.http.server.HTTPServerRequest, vibe.http.server.HTTPServerResponse)+0x68) [0x5b0f20]
/tmp/dub/4191021397/webserver(void vibe.http.router.URLRouter.handleRequest(vibe.http.server.HTTPServerRequest, vibe.http.server.HTTPServerResponse)+0x179) [0x639479]
/tmp/dub/4191021397/webserver(bool vibe.http.server.handleRequest(vibe.core.stream.Stream, immutable(char)[], vibe.http.server.HTTPServerListener, ref vibe.http.server.HTTPServerSettings, ref bool)+0x162e) [0x640c56]
/tmp/dub/4191021397/webserver(void vibe.http.server.handleHTTPConnection(vibe.core.net.TCPConnection, vibe.http.server.HTTPServerListener)+0x143) [0x63f563]
/tmp/dub/4191021397/webserver(void vibe.http.server.listenHTTPPlain(vibe.http.server.HTTPServerSettings, void delegate(vibe.http.server.HTTPServerRequest, vibe.http.server.HTTPServerResponse)).void doListen(vibe.http.server.HTTPServerSettings, vibe.http.server.HTTPServerListener, immutable(char)[]).void __lambda110(vibe.core.net.TCPConnection)+0x2c) [0x63bb44]
/tmp/dub/4191021397/webserver(extern (C) nothrow void vibe.core.drivers.libevent2_tcp.onConnect(int, short, void*).void ClientTask.execute()+0x2d6) [0x5e6506]
/tmp/dub/4191021397/webserver(void vibe.core.core.CoreTask.run()+0xf2) [0x606c6a]
/tmp/dub/4191021397/webserver(void core.thread.Fiber.run()+0x2a) [0x6ac9f2]
/tmp/dub/4191021397/webserver(fiber_entryPoint+0x61) [0x6ac8fd]
[(nil)]

Do you have any idea, why this is happening?

Thanks