Articles → MONGODB → $Substrcp Aggregation Function In Mongodb
$Substrcp Aggregation Function In Mongodb
Purpose
Syntax
{ $substrCP: [ <string>, <start>, <length> ] }
Example
db.Employees.aggregate([
{
$project: {
name: { $substrCP: ["$firstname", 0, 2] }
}
}
])
Output