Smart hasMany relationship in mongoDB

Version Details

"mongoose": "^5.11.19",
"forest-express-mongoose": "^8.4.3",
"express": "~4.17.1",

with Typescript.

I am essentially trying to create a hasMany smart relationship between an organization and its users.

My forest/organizations file with the smart field declared.

My route controller. Here, I am successfully receiving the request. Then my ‘findUserOfOrganization’ function retrieves an array of user objects that are part of that organization.

I am confused on how to serialize and return the users. The documentation here is not helpful. Can someone share a sample code snippet to execute this?

Thanks and any assistance will be highly appreciated :pray: :blush:

Hello @dev_support Any solution in this regard?

Is it not working, or just refusing to build because of the typechecking?
Can you try casting users to Record<string, any>[]?

Hello, Thank you for response. I found that the issue was not declaring the type of users in parameter. When I did that, the serialize function took the value. You can see the solution below.

1 Like