Skip to content

Create searching-by-dbref feature #90

@pmaselkowski

Description

@pmaselkowski

Scenario:

  1. I want to find Projects which reference Organization
  2. I create Criteria object
  3. I add condition as a instance of Organization

Current:

  1. Nothing happens/error/unknown

Expected:

  1. 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")

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions