Scenario:
- I want to find
Projects which reference Organization
- I create
Criteria object
- I add condition as a instance of
Organization
Current:
- Nothing happens/error/unknown
Expected:
- Conditions are generated to match documents based on type of passed instance and PK of passed instance, which are stored in
Project as DbRef
Example document:
{
"_id" : ObjectId("5de7b9c7a9ab701fb64f8622"),
"createUserId" : "578531300a9907a9568b4941",
"_class" : "Maslosoft\\Fc\\Tracker\\Models\\Project",
"createDate" : ISODate("2019-12-04T13:51:54.717Z"),
"createUser" : "piotr",
"id" : ObjectId("5de7b9c7a9ab701fb64f8622"),
"name" : "Test2",
"orgName" : "Maslosoft",
"organization" : {
"class" : "Maslosoft\\Orgs\\Models\\MyOrganization",
"pk" : ObjectId("58f77766b7cd245d0f03c651"),
"_class" : "Maslosoft\\Mangan\\Model\\DbRef"
},
"updateDate" : ISODate("2019-12-04T13:51:54.717Z"),
"updateUser" : "piotr",
"updateUserId" : "578531300a9907a9568b4941",
"wasSaved" : false
}
Assuming that instance of Organization is provided as condition for organization field, ie:
$organization = Organization::model()->findByPk('58f77766b7cd245d0f03c651');
$criteria = new Criteria(null, new Project);
$criteria->addCond('organization', '==', $organization);
Generated conditions should match in Project:
organization.class: "Maslosoft\\Orgs\\Models\\MyOrganization"
organization.pk: ObjectId("58f77766b7cd245d0f03c651")
Scenario:
Projects which referenceOrganizationCriteriaobjectOrganizationCurrent:
Expected:
ProjectasDbRefExample document:
{ "_id" : ObjectId("5de7b9c7a9ab701fb64f8622"), "createUserId" : "578531300a9907a9568b4941", "_class" : "Maslosoft\\Fc\\Tracker\\Models\\Project", "createDate" : ISODate("2019-12-04T13:51:54.717Z"), "createUser" : "piotr", "id" : ObjectId("5de7b9c7a9ab701fb64f8622"), "name" : "Test2", "orgName" : "Maslosoft", "organization" : { "class" : "Maslosoft\\Orgs\\Models\\MyOrganization", "pk" : ObjectId("58f77766b7cd245d0f03c651"), "_class" : "Maslosoft\\Mangan\\Model\\DbRef" }, "updateDate" : ISODate("2019-12-04T13:51:54.717Z"), "updateUser" : "piotr", "updateUserId" : "578531300a9907a9568b4941", "wasSaved" : false }Assuming that instance of
Organizationis provided as condition fororganizationfield, ie:Generated conditions should match in
Project: