Open
Description
I have the following schema defined
class Workspace(JsonModel):
id: str = Field(index=True)
title: str = Field(index=True)
users: List[User] = Field(index=True)
class User(EmbeddedJsonModel):
id: str = Field(index=True)
name: str = Field(index=True)
type: str = Field(index=True)
I can't find an example like this in the documentation but if I had a Workspace saved how could I search for a User associated with that Workspace. From what I understand I have to start the search on Workspace and drill down to the users list.
From the documentation on the "skill" of a Person example I assume it would look something like this, but I haven't had success getting this to work.
user = Workspace.find(Workspace.users << User(**{"name": "John Doe"})).all()
Update/Edit.
The schema update to have User not be an EmbeddedJsonModel
still doesn't function as expected, and no results are found.
The Migrator created a search index for both Workspace as well as User but it's not
clear how to take advantage of the User search index because no searches return values
class Workspace(JsonModel):
id: str = Field(index=True)
title: str = Field(index=True)
users: List[User] = Field(index=True)
class Users(JsonModel):
id: str = Field(index=True)
name: str = Field(index=True)
type: str = Field(index=True)
Stored Json
{
"pk": "01GSWNGTT7WXD7NGHPN1XPGNQQ",
"id": "6",
"title": "Test Workspace",
"users": [
"0": {
"pk": "01GSWNGTT7CMACEE55FSWKCVHQ",
"id": "30",
"name": "John",
"type": "registered",
}
]
}
User.find((User.name == "John")).all()
Returns "[]"