@tmlmobilidade/interfaces
Version:
This package provides SDK-style connectors for interacting with databases (e.g., stops, plans, rides, alerts) and external providers (e.g., authentication, storage). It simplifies data access and integration across projects.
57 lines (56 loc) • 1.49 kB
TypeScript
import { type OptionalIf } from '@tmlmobilidade/types';
import { Filter } from 'mongodb';
interface MatchStage<T> {
$match: Filter<T>;
}
interface ProjectStage<T> {
$project: Partial<Record<keyof T, 0 | 1> | Record<string, 0 | 1>>;
}
interface GroupStage {
$group: {
[key: string]: any;
_id: Record<string, any> | string;
};
}
interface ReplaceRootStage {
$replaceRoot: {
newRoot: Record<string, any> | string;
};
}
interface SortStage<T> {
$sort: Partial<Record<keyof T, -1 | 1> | Record<string, -1 | 1>>;
}
interface LimitStage {
$limit: number;
}
interface SkipStage {
$skip: number;
}
interface UnwindStage {
$unwind: string | {
path: string;
preserveNullAndEmptyArrays: boolean;
};
}
interface AddFieldsStage {
$addFields: Record<string, any>;
}
interface LookupStage {
$lookup: OptionalIf<{
as: string;
foreignField?: string;
from: string;
let?: Record<string, any>;
localField?: string;
pipeline?: any[];
}, 'pipeline', 'foreignField' | 'localField'>;
}
interface SetStage {
$set: Record<string, any>;
}
interface UnsetStage {
$unset: string | string[];
}
type AggregationStage<T> = AddFieldsStage | GroupStage | LimitStage | LookupStage | MatchStage<T> | ProjectStage<T> | ReplaceRootStage | SetStage | SkipStage | SortStage<T> | UnsetStage | UnwindStage;
export type AggregationPipeline<T> = AggregationStage<T>[];
export {};