Conditional findFirst

Is it possible to conditionally use findFirst, rather than having to chain the underlying model.

E.g.

const result = await db.query.users.findMany({
    with: {
        posts: true            
    },
});

Into either:

const result = await db.query(users).findMany({
    with: {
        posts: true            
    },
});

OR

const result = await db.query[modelName]findMany({
    with: {
        posts: true            
    },
});
Was this page helpful?