in src/mongo/services/schemaService.ts [208:391]
private setOperatorProperties(type: string, schema: JSONSchema): void {
if (!schema.properties) {
schema.properties = {};
}
const expressionSchema = {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
properties: <any>{}
};
// Comparison operators
expressionSchema.properties.$eq = {
type: type,
description: 'Matches values that are equal to a specified value'
};
expressionSchema.properties.$gt = {
type: type,
description: 'Matches values that are greater than a specified value'
};
expressionSchema.properties.$gte = {
type: type,
description: 'Matches values that are greater than or equal to a specified value'
};
expressionSchema.properties.$lt = {
type: type,
description: 'Matches values that are less than a specified value'
};
expressionSchema.properties.$lte = {
type: type,
description: 'Matches values that are less than or equal to a specified value'
};
expressionSchema.properties.$ne = {
type: type,
description: 'Matches all values that are not equal to a specified value'
};
expressionSchema.properties.$in = {
type: 'array',
description: 'Matches any of the values specified in an array'
};
expressionSchema.properties.$nin = {
type: 'array',
description: 'Matches none of the values specified in an array'
};
// Element operators
expressionSchema.properties.$exists = {
type: 'boolean',
description: 'Matches documents that have the specified field'
};
expressionSchema.properties.$type = {
type: 'string',
description: 'Selects documents if a field is of the specified type'
};
// Evaluation operators
expressionSchema.properties.$mod = {
type: 'array',
description: 'Performs a modulo operation on the value of a field and selects documents with a specified result',
maxItems: 2,
default: [2, 0]
};
expressionSchema.properties.$regex = {
type: 'string',
description: 'Selects documents where values match a specified regular expression'
};
// Geospatial
const geometryPropertySchema: JSONSchema = {
type: 'object',
properties: {
type: {
type: 'string',
default: 'GeoJSON object type'
},
coordinates: {
type: 'array'
},
crs: {
type: 'object',
properties: {
type: {
type: 'string'
},
properties: {
type: 'object'
}
}
}
}
};
expressionSchema.properties.$geoWithin = {
type: 'object',
description: 'Selects geometries within a bounding GeoJSON geometry. The 2dsphere and 2d indexes support $geoWithin',
properties: {
$geometry: geometryPropertySchema,
$box: {
type: 'array'
},
$polygon: {
type: 'array'
},
$center: {
type: 'array'
},
$centerSphere: {
type: 'array'
}
}
};
expressionSchema.properties.$geoIntersects = {
type: 'object',
description: 'Selects geometries that intersect with a GeoJSON geometry. The 2dsphere index supports $geoIntersects',
properties: {
$geometry: geometryPropertySchema
}
};
expressionSchema.properties.$near = {
type: 'object',
description: 'Returns geospatial objects in proximity to a point. Requires a geospatial index. The 2dsphere and 2d indexes support $near',
properties: {
$geometry: geometryPropertySchema,
$maxDistance: {
type: 'number'
},
$minDistance: {
type: 'number'
}
}
};
expressionSchema.properties.$nearSphere = {
type: 'object',
description: 'Returns geospatial objects in proximity to a point. Requires a geospatial index. The 2dsphere and 2d indexes support $near',
properties: {
$geometry: geometryPropertySchema,
$maxDistance: {
type: 'number'
},
$minDistance: {
type: 'number'
}
}
};
// Array operatos
if (type === 'array') {
expressionSchema.properties.$all = {
type: 'array',
description: 'Matches arrays that contain all elements specified in the query'
};
expressionSchema.properties.$size = {
type: 'number',
description: 'Selects documents if the array field is a specified size'
};
}
// Bit operators
expressionSchema.properties.$bitsAllSet = {
type: 'array',
description: 'Matches numeric or binary values in which a set of bit positions all have a value of 1'
};
expressionSchema.properties.$bitsAnySet = {
type: 'array',
description: 'Matches numeric or binary values in which any bit from a set of bit positions has a value of 1'
};
expressionSchema.properties.$bitsAllClear = {
type: 'array',
description: 'Matches numeric or binary values in which a set of bit positions all have a value of 0'
};
expressionSchema.properties.$bitsAnyClear = {
type: 'array',
description: 'Matches numeric or binary values in which any bit from a set of bit positions has a value of 0'
};
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
schema.properties = { ...expressionSchema.properties };
schema.properties!.$not = {
type: 'object',
description: 'Inverts the effect of a query expression and returns documents that do not match the query expression',
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
properties: { ...expressionSchema.properties }
};
schema.properties!.$elemMatch = {
type: 'object'
};
}