✨ feat: unify API options structure and enhance lookup handling across collections
This commit is contained in:
@@ -104,9 +104,10 @@ function ssrRequest(cacheKey, endpoint, query, options) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (options && options.params && options.params.aggregate) {
|
||||
const aggregates = typeof options.params.aggregate === "string"
|
||||
? options.params.aggregate.split(",")
|
||||
const rawAggregate = (options && options.aggregate) || (options && options.params && options.params.aggregate);
|
||||
if (rawAggregate) {
|
||||
const aggregates = typeof rawAggregate === "string"
|
||||
? rawAggregate.split(",")
|
||||
: [];
|
||||
for (const a of aggregates) {
|
||||
// simple format: "collectionName:foreignField:..."
|
||||
|
||||
@@ -72,6 +72,7 @@ function apiRequest(endpoint, options, body, sentry) {
|
||||
if (options?.offset) query += "&offset=" + options.offset
|
||||
if (options?.projection) query += "&projection=" + options.projection
|
||||
if (options?.lookup) query += "&lookup=" + options.lookup
|
||||
if (options?.aggregate) query += "&aggregate=" + (typeof options.aggregate === 'string' ? options.aggregate : encodeURIComponent(JSON.stringify(options.aggregate)))
|
||||
|
||||
if (options?.params) {
|
||||
Object.keys(options.params).forEach((p) => {
|
||||
|
||||
Reference in New Issue
Block a user