Closed
Description
Take the following code:
app('db')->connection('mongodb')->table($collectionName)
->where($key, $value)->value($propertyName);
If using mysql, it runs a query like:
SELECT $propertyName FROM $collectionName WHERE $key = $value LIMIT 1
And it returns the value of $propertyName.
However, due to the fact that mongo always returns the _id
, whenever you use a projection, this method always returns _id
, instead of $propertyName
This method should be overriden with something like:
public function value($column)
{
$result = (array) $this->first([$column]);
return $result[$column] ?? null;
}
Metadata
Metadata
Assignees
Labels
No labels