I have 2 entities as following:
Project can't have the ref to freelancer as there could be many freelancers who can bid the projects. I want do following:
Find the freelancer who has placed a bid on project with name = "XYZ".
What should be the query (JSON based Query) for this, i tried following (other combinations but nothing works):
@Query("{ 'completedProject': {'$ref': 'project', 'name': ?0 } }")
@Query("{ 'completedProjects': {'$ref': 'project', 'name': ?0 } }")
@Query("{ 'completedProject': [{'$ref': 'project', 'name': ?0 }] }")
Code:
@Document
public class Freelancer {
@Id
String id;
String name;
@DbRef
List<Project> bidProjects;
}
@Document
public class Project {
@Id
String id;
String name;
}
Find the freelancer who has placed a bid on project with name = "XYZ".
What should be the query (JSON based Query) for this, i tried following (other combinations but nothing works):
@Query("{ 'completedProject': {'$ref': 'project', 'name': ?0 } }")
@Query("{ 'completedProjects': {'$ref': 'project', 'name': ?0 } }")
@Query("{ 'completedProject': [{'$ref': 'project', 'name': ?0 }] }")