Wednesday, February 28, 2018

whereNotBetween not working as expected - development

whereNotBetween not working as expected

I am trying to exclude a given range of ids when I select the records and I am trying to use whereNotBetween()

But it returns all the records instead of the records which does not have id in the given range. and yes the id is a mongodb string type.

    return Contact::whereNotBetween('id', ["1","2"])->get();

I don’t think it’s an issue with string keys as whereBetween() works just fine with string keys.

The Schema is something like this:

{
    "_id": "5a9633de072e10085205c912",
    "id": "1",
    "name": "sapnesh",
    "nick_name": "sap",
    "address": {
        "permanent": {
            "city": "Karwar",
            "state": "Karnataka",
            "PinCode": "581324"
        },
        "temperory": {
            "city": "Bangalore",
            "state": "Karnataka",
            "PinCode": "560040"
        }
    },
    "updated_at": "2018-02-28 04:45:18",
    "created_at": "2018-02-28 04:45:18"
}

What is the issue here?



from Laravel Questions and Answers https://laravelquestions.com/laravel/wherenotbetween-not-working-as-expected/
via Lzo Media

No comments:

Post a Comment