Please note, "user_id" in my plans
collection is NOT an object_id. I have it stored in the plans
collection to reference the user's _id in the user_accounts
collection. I thought about storing usernames across all collections in order to reference the user, but that wouldn't be idea should the user wishes to change his/her username.
// Retrieve User ID
$query = array("username" => $user_id);
$fields = array("_id");
$user = $collection_user->findOne($query, $fields);
// Retrieve plans made by user
$query = array("user_id" => $user['_id']);
$fields = array("plan_title");
$data = $collection_plans->find($query, $fields);
If I hardcode the _id into the query it works fine as follows:
// Retrieve plans made by user
$query = array("user_id" => "4cc1790f6c0d49bf9424fc73");
$fields = array("plan_title");
$data = $collection_plans->find($query, $fields);