Skip to content

Ability to call toJSON() over a search result #1

@destegabry

Description

@destegabry

Maybe I'm doing something wrong, I'm going to start using your great and simple class to perform querying in my webapp.
To retrieve a list of users I'm doing this:

$users = new User();
$users = $users->search();

$list = array();
foreach($users as $u)
    array_push($list, $u->toJSON());
$res->body(json_encode($list, JSON_UNESCAPED_SLASHES ));

Is there a better way to achieve this?

Edit:
I'm doing the foreach sillness to avoid the even sillier _id:{$id:"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"} in my results

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions