Coder Social home page Coder Social logo

Comments (14)

jenssegers avatar jenssegers commented on June 12, 2024

I did not look into pagination yet, I will try to add it today.

from laravel-mongodb.

leekaiwei avatar leekaiwei commented on June 12, 2024

Oh I see. Thanks.

EDIT: Actually what I want to do requires take() and skip() instead, so currently I don't need paginate() for now.

from laravel-mongodb.

jenssegers avatar jenssegers commented on June 12, 2024

Pagination was actually working already when I tried it.

$reports = Report::paginate(5);

Returned me 5 items, and pagination links.

from laravel-mongodb.

leekaiwei avatar leekaiwei commented on June 12, 2024

Interesting, no matter where I put the call to pagination method in the chain, it wouldn't work.

from laravel-mongodb.

jenssegers avatar jenssegers commented on June 12, 2024

Take and skip is working as well, those are tested by unittests.

from laravel-mongodb.

jenssegers avatar jenssegers commented on June 12, 2024

Can I see your chain?

from laravel-mongodb.

leekaiwei avatar leekaiwei commented on June 12, 2024

Yes they are working fine.

User::where('attribute', 'value')->orderBy('attribute')->paginate(number);

from laravel-mongodb.

jenssegers avatar jenssegers commented on June 12, 2024

I was able to execute the following without any errors:

$reports = Report::where('node', 'vmware2')->orderBy('elapsed')->paginate(5);

But when I look at your error message, the query builder started using the aggregation framework. Did you use any grouping or aggregation somewhere else or in the same query?

from laravel-mongodb.

leekaiwei avatar leekaiwei commented on June 12, 2024

Not to my knowledge. If I have, then I've used it without knowing. I have 2 weeks experience of PHP/Laravel. If you say it works, then it probably does and I've done something stupid.

Off-topic: Since MongoDB can have arrays inserted into them, does this package support something like where() but for matching an item in the array? Currently doing it manually and therefore cannot use Eloquent methods, making things like skip() and take() a bit harder.

from laravel-mongodb.

jenssegers avatar jenssegers commented on June 12, 2024

Yes, you can just use something like this:

User::where('address.country', 'France')->get();

from laravel-mongodb.

leekaiwei avatar leekaiwei commented on June 12, 2024

I think we are thinking of slightly different arrays. I was thinking of having inserted:

array('tag1', 'tag2', 'games', 'entertainment')

into a field tags. Then I would want to find all models in which its array in tags contain for example games. There isn't anything like that is there?

from laravel-mongodb.

jenssegers avatar jenssegers commented on June 12, 2024

You can use this query for that:

Post::where('tags', 'games')->get();

Check 92754b8

from laravel-mongodb.

leekaiwei avatar leekaiwei commented on June 12, 2024

Oh I see. So that does work. Thanks very much for your help. Much appreciated.

from laravel-mongodb.

khungdisan avatar khungdisan commented on June 12, 2024

How to conver to array when use pagination.
I using Laravel 5.4 and jensseger mongodb 3.2

from laravel-mongodb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.