How to limit an array size in MongoDB? -
is there way can limit number of elements can added mongodb array? have tables collection attendees array should contain 10 elements seats).
thank you!
you can use $slice modifier $push when update document:
$push: {"field": $each: ["val1", "val2"], $slice: -10} this cause field consist of last 10 elements (giving "rolling window" of values pushed field).
Comments
Post a Comment