高性能mongodb之利用javascript函数式编程玩转mongodb shell

栏目: JavaScript · 发布时间: 7年前

内容简介:命令一集合记录数列表: db.getCollectionNames().forEach((name) => {print(name+","+db[name].stats().count)})快速展示mongo所有集合和集合的文档数,但是没有做排序。命令二集合按记录条数排序: db.getCollectionNames().map((name) => db[name]).sort((a,b) => {return a.count()-b.count()}).forEach((db) => {print(db.

我的专栏地址: 我的segmentfault,欢迎浏览

命令一集合记录数列表: db.getCollectionNames().forEach((name) => {print(name+","+db[name].stats().count)})

快速展示mongo所有集合和集合的文档数,但是没有做排序。

>  db.getCollectionNames().forEach((name) => {print(name+","+db[name].stats().count)})

log.login_online,2673475
log.challenge_result,390836
log.order,2674511
log.animal,1534481
log.animal_arrest,1095140

命令二集合按记录条数排序: db.getCollectionNames().map((name) => db[name]).sort((a,b) => {return a.count()-b.count()}).forEach((db) => {print(db.getName()+","+db.count())})

快速展示mongo所有集合和集合的文档数,并排好序。运用知识:map、sort、forEach

>db.getCollectionNames().map((name) => db[name]).sort((a,b) => {return a.count()-b.count()}).forEach((db) => {print(db.getName()+","+db.count())})

log.challenge_result,390836
log.animal_arrest,1095140
log.animal,1534481
log.login_online,2673475
log.order,2674511

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。

The Information

The Information

James Gleick / Vintage / 2012-3-6 / USD 16.95

James Gleick, the author of the best sellers Chaos and Genius, now brings us a work just as astonishing and masterly: a revelatory chronicle and meditation that shows how information has become th......一起来看看 《The Information》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

html转js在线工具
html转js在线工具

html转js在线工具