SELECT "t0"."name" AS "name", (
SELECT COALESCE(json_agg("s"."j" ORDER BY "s"."rn"), '[]'::json)
FROM (
SELECT json_build_object('title', "t1"."title", 'views', "t1"."views") AS "j", ROW_NUMBER() OVER (ORDER BY "t1"."views" DESC) AS "rn"
FROM "posts" "t1"
WHERE "t1"."authorId" = "t0"."id" AND ("t1"."published" = $1)
ORDER BY "t1"."views" DESC
LIMIT 3
) "s"
) AS "posts"
FROM "users" "t0"
WHERE "t0"."email" LIKE $2 ESCAPE '!'
SELECT `t0`.`name` AS `name`, (
SELECT COALESCE(JSON_ARRAYAGG(CAST(`s`.`j` AS JSON)), JSON_ARRAY())
FROM (
SELECT JSON_OBJECT('title', `t1`.`title`, 'views', `t1`.`views`, '__kastor_rn', ROW_NUMBER() OVER (ORDER BY `t1`.`views` DESC)) AS `j`
FROM `posts` `t1`
WHERE `t1`.`authorId` = `t0`.`id` AND (`t1`.`published` = ?)
ORDER BY `t1`.`views` DESC
LIMIT 3
) `s`
) AS `posts`
FROM `users` `t0`
WHERE `t0`.`email` LIKE ? COLLATE utf8mb4_bin ESCAPE '!'
SELECT "t0"."name" AS "name", (
SELECT json_group_array(json("s"."j"))
FROM (
SELECT json_object('title', "t1"."title", 'views', "t1"."views", '__kastor_rn', ROW_NUMBER() OVER (ORDER BY "t1"."views" DESC)) AS "j"
FROM "posts" "t1"
WHERE "t1"."authorId" = "t0"."id" AND ("t1"."published" = ?)
ORDER BY "t1"."views" DESC
LIMIT 3
) "s"
) AS "posts"
FROM "users" "t0"
WHERE substr("t0"."email", -length(?)) = ?
SELECT [t0].[name] AS [name], COALESCE((
SELECT TOP (3) [t1].[title] AS [title], [t1].[views] AS [views]
FROM [posts] [t1]
WHERE [t1].[authorId] = [t0].[id] AND ([t1].[published] = @p1)
ORDER BY [t1].[views] DESC
FOR JSON PATH, INCLUDE_NULL_VALUES
), '[]') AS [posts]
FROM [users] [t0]
WHERE [t0].[email] COLLATE Latin1_General_100_BIN2 LIKE @p2 ESCAPE '!'
SELECT "t0"."name" AS "name", (
SELECT JSON_ARRAYAGG("s"."j" FORMAT JSON ORDER BY "s"."rn" RETURNING CLOB)
FROM (
SELECT JSON_OBJECT('title' VALUE "t1"."title", 'views' VALUE "t1"."views" NULL ON NULL RETURNING CLOB) AS "j", ROW_NUMBER() OVER (ORDER BY "t1"."views" DESC) AS "rn"
FROM "posts" "t1"
WHERE "t1"."authorId" = "t0"."id" AND ("t1"."published" = :1)
ORDER BY "t1"."views" DESC
FETCH NEXT 3 ROWS ONLY
) "s"
) AS "posts"
FROM "users" "t0"
WHERE "t0"."email" LIKE :2 ESCAPE '!'
{
"aggregate": "users",
"pipeline": [
{
"$match": {
"email": {
"$regularExpression": {
"pattern": "@acme\\.com\\z",
"options": ""
}
}
}
},
{
"$lookup": {
"from": "posts",
"let": {
"k0": "$_id"
},
"pipeline": [
{
"$match": {
"$expr": {
"$and": [
{
"$eq": [
"$authorId",
"$$k0"
]
},
{
"$ne": [
"$$k0",
null
]
}
]
}
}
},
{
"$match": {
"published": {
"$eq": true
}
}
},
{
"$sort": {
"views": -1,
"_id": 1
}
},
{
"$limit": 3
},
{
"$project": {
"_id": 0,
"title": "$title",
"views": "$views"
}
}
],
"as": "__i0"
}
},
{
"$project": {
"_id": 0,
"name": "$name",
"posts": "$__i0"
}
}
],
"cursor": {}
}