MongoDB是一个介于关系数据库和非关系数据库之间的产品,是非关系数据库当中功能最丰富,最像关系数据库的。它支持的数据结构非常松散,是类似json的bson格式,因此可以存储比较复杂的数据类型。
example = {_id: "XXX", text: "YYY"}
db.example.aggregate([
{$project : {text : 1, length : {$size : "$text"}}},
{$sort : {length : 1}}
]);
I think this will do the job, but only for mongo 2.6 and above