sequelize-typescript
sequelize-typescript copied to clipboard
Question: how to proper type the return type ?
Question
Scenario: I have a custom query like this:
const results = await User.findAll({
attributes: [
"name",
[cast(fn("COUNT", col("Posts.id")), "boolean"), "hasPosts"],
],
include: {
model: Post,
attributes: [],
required: false,
},
group: ["User.id", "Post.id"],
});
Can I (explicit or not) have result
as:
interface ResultType {
name: string;
hasPosts: boolean;
}
Stretching a little bit: is there a way to make the result type to only have the properties included in the attributes
?
Side question: could we have GitHub Discussions enable in this repo?
@Falci One year later, did U find a way to have an explicit result type?
@Falci One year later, did U find a way to have an explicit result type?
No