PostgreSQL Specific Features
const comments = await EntComment.select(
vc,
{ creator_id: "101" },
20,
undefined, // order
custom, // untyped, but of type SelectInputCustom
);type SelectInputCustom ={
ctes?: Literal[];
joins?: Literal[];
from?: Literal;
hints?: Record<string, string>;
}const comments = await EntComment.select(
vc,
{ created_at: { $gt: yesterdayDate } },
10,
[{ created_at: "DESC" }],
{
// WITH clauses (Common Table Expressions).
ctes: [
[
"recent_topics AS (SELECT * FROM topics WHERE created_at > ?)",
yesterdayDate,
],
[
"recent_comments AS (SELECT * FROM comments WHERE created_at > ?)",
yesterdayDate,
],
],
// A replacement for the entire FROM clause.
from: ["recent_comments"],
// Clauses after FROM.
joins: [
[
"JOIN recent_topics t ON t.id = topic_id AND comment_count > ?",
minComments,
],
],
// Parameters like enable_seqscan, enable_bitmapscan etc.
hints: {
enable_seqscan: "off",
}
);Last updated