Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create searching-by-dbref feature #90

Open
pmaselkowski opened this issue Dec 4, 2019 · 0 comments
Open

Create searching-by-dbref feature #90

pmaselkowski opened this issue Dec 4, 2019 · 0 comments

Comments

@pmaselkowski
Copy link
Member

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")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant