I'm currently working on a matching algorithm that calculates a score between two differents products lists.
I'm using mongodb aggregations to add a matching-score field calculated with differents arguments. Actually, the algorithm needs to know the position of each product in the list. So I thought to dynamically add a position field on each product to use it later.
I don't know which mongodb aggregation operator I have to use. Maybe someone can help me ?
Here is my list model :
const listSchema = mongoose.Schema({
type: { type: mongoose.Schema.Types.ObjectId, ref: "ListType", required: true },
links: [{
brand: { type: mongoose.Schema.Types.ObjectId, ref: "Brand", required: true },
work: { type: mongoose.Schema.Types.ObjectId, ref: "Product" },
}],
associatedUser: { type: mongoose.Schema.Types.ObjectId, ref: "User", required: true }
}, { versionKey: false });
In advance thank you,
Pierre
linksarray just in reads via aggregation but not to update actual doc in collection ?