Skip to content

Improve methods to abstract queries on MongoDB #68

@rplansky

Description

@rplansky

Currently, if we need to perform a query using Model class, we need to know too much about how query works in MongoDB.

The idea is to create some methods to abstract these queries.

Examples

Today

$posts = Post::find(['tag' => 'mongolid', 'approved' => true])
    ->limit($limit)
    ->skip(($page - 1) * $limit)
    ->sort(['created_at' => -1]);

Suggestion

$posts = Post::tag('mongolid')
    ->approved(true)
    ->newest()
    ->get($limit, $page);

Note: We would still be able to use the "old" method.

We need to talk a little bit about it :P

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions