Missing remove() and findOne() for Ids?

Issue #1 resolved
Alexander Orlov
created an issue

It seems that the equivalent for

db.myCollection.remove({"_id" : ObjectId("4f8d7ecc537dfffbf055c59d")});

is missing. Also there is no equivalent for

db.myCollection.findOee({"_id" : ObjectId("4f8d7ecc537dfffbf055c59d")});

Comments (6)

  1. vadimtsushko repo owner

    Alexandr, examining tests I've found that there are some cases of usage findOne with ObjectId. Take a look on testSaveWithObjectId in DbCollectionTest.dart. ....

     List toInsert = [
                       {"name":"a", "value": 10},
                       {"name":"b", "value": 20},
                       {"name":"c", "value": 30},
                       {"name":"d", "value": 40}
        return coll.findOne({"name":"c"});
        new Expectation(v["value"]).equals(30);
        id = v["_id"];    
        return coll.findOne({"_id":id});

    there id = v["_id"] set value of id to actual ObjectId value, and then use it in findOne() query

  2. vadimtsushko repo owner

    But I've aslo found that using query helper for same operation raised type exception in checked mode.

          id = val["_id"];
          return coll.findOne(query().eq("_id", id));

    I'll check it futher.

  3. vadimtsushko repo owner

    Alexandr, I've added samples for findOne and remove operations filtered by ObjectId in both modes: Raw as in

    coll.findOne({"_id": id});

    And with query helper as in


    Samples are in examples in raw_queries.dart and queries.dart respectively. Actually before that did not work only second mode. Tentatively set issue status as resolved - let me know if something is still not working for you

  4. Log in to comment