Mango DB: v3.3.1
Laravel 5.5
Other packages: Datatables
I'm trying to use the query builder with datatables that makes the query based on params and etc, but Mango freaks out with the limit feature. It throws the error:
MongoDB\Exception\InvalidArgumentException: Expected "limit" option to have type "integer" but found "string" in I:\xampp\htdocs\ngis\vendor\mongodb\mongodb\src\Exception\InvalidArgumentException.php:32
Stack trace:
#0 I:\xampp\htdocs\ngis\vendor\mongodb\mongodb\src\Operation\Find.php(183):
Which I know if you type cast, it's fine, but is there a reason why Mongo isn't able to type cast? I couldn't figure out where Datatables is trying to build the query. It's similar to this issue: https://github.com/yajra/laravel-datatables/issues/1442
THANKS!
You have to use "intval" in both function of take && skip
$trans = DB::collection("collection_name")
->take( intval($limit) )
->skip( intval($skip) )->get();
You have to use "intval" in both function of take && skip
$trans = DB::collection("collection_name") ->take( intval($limit) ) ->skip( intval($skip) )->get();
I have a similar problem but after print this: ErrorException: Illegal offset type in /var/www/html/vendor/jenssegers/mongodb/src/Jenssegers/Mongodb/Query/Builder.php:383
Most helpful comment
You have to use "intval" in both function of take && skip