A
A
Artem2015-07-30 23:43:12
PHP
Artem, 2015-07-30 23:43:12

How to get only one mongodb field in fat-free framework?

Help me please. Is it possible in some unknown way to get only one (or several) fields from MongoDB, and not all at once? Or is it so arranged that it returns the entire document? It's just extra data, and if I only need the 'pashash' value, it's stupid to load the entire object.
In SQL analogue: SELECT `passhash` FROM ... I did not find an example
in the documentation .
The data is loaded like this:

$db=new DB\Mongo('mongodb://localhost:27017','testdb');
$user=new DB\Mongo\Mapper($db,'users');
$user->load(array('login'=>'admin')); // подозреваю что при вызове грузится весь документ
echo $user->passhash; // выведет значение поля passhash

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kano, 2015-07-31
@ber_enot

Use projections when filtering link
db.things.find({}, {passhash:true})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question