// 获取前100条数据字段
var allKeys = {};
var i = 0;
db.caTxnDetl.find().sort({_id:-1}).limit(100).forEach(
function(doc){
var array = []
Object.keys(doc).forEach(
function(key){
array.push(key)
}
)
allKeys[i++] = array;
}
);
print(allKeys)
// 获取前100条数据最长字段
var allKeys = [];
db.caTxnDetl.find().sort({_id:-1}).limit(100).forEach(
function(doc){
var array = []
Object.keys(doc).forEach(
function(key){
array.push(key)
}
)
if (array.length > allKeys.length){
allKeys = array;
}
}
);
print(allKeys)
06-24
7万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
06-17
1万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)