Nested object in select query?

Drizzle-orm 0.29.3. My code is

    const feedbacks = await drizzleClient
        .select({
            ...getTableColumns(feedbackFirst),
            project: {
                ...getTableColumns(project),
            },
            userFrom: {
                ...getTableColumns(users),
                userAbout: {
                    ...getTableColumns(userAbout),
                    avatar: {
                        ...getTableColumns(avatars),
                        photo: {
                            ...getTableColumns(photos),
                        }
                    }
                }
            }
        })
        .from(feedbackFirst)
        .innerJoin(project, eq(project.prid, feedbackFirst.prid))
        .innerJoin(users, eq(users.uid, feedbackFirst.uidFrom))
        .innerJoin(userAbout, eq(userAbout.uid, users.uid))
        .innerJoin(avatars, eq(avatars.uid, users.uid))
        .innerJoin(photos, eq(photos.phid, avatars.phid))

There is an error near
avatar

Object literal may only specify known properties, and avatar does not exist in type


Despite of the type error, the query result is correct, with all nesting. How to fix the type error? And is it possible?
2024-03-20_16.33.18.png
Was this page helpful?