-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
ReArc BackendThis concerns either the backend itself or the client -> server connectionThis concerns either the backend itself or the client -> server connectionRefactoringThis issue refactors a part of the codebaseThis issue refactors a part of the codebase
Milestone
Description
Right now we make database calls such as this:
const tokens = await Tokens.find<Token>({});Which is fine, but as soon as we try to spread it, like so:
const x = tokens.map((t) => ({ ...t, value: undefined });We end up with this weird mongoose object that contains the actual data in the _doc property. This is why we have so many _doc calls in ReArc, for instance:
const shares = await getUserShares(user._id.toString());
res.json(
shares.map((s) => ({
...(s as any)._doc,
passwordHash: undefined,
}))
);We need to change getUserShares in this case to return the JSON representation of the data:
export async function getUserShares(userId: string): Promise<SharedDrive[]> {
- return await SharedDrives.find<SharedDrive>({ userId });
+ return (await SharedDrives.find({ userId })).map((share) => share.toJSON());
}This has to be done for every database operation, just to clean up the codebase and to minimize confusion.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
ReArc BackendThis concerns either the backend itself or the client -> server connectionThis concerns either the backend itself or the client -> server connectionRefactoringThis issue refactors a part of the codebaseThis issue refactors a part of the codebase