async toJson()

in lib/Collection.ts [78:106]


  async toJson(): Promise<CollectionJSON> {
    let stats = {
      size: 0,
      count: 0,
      avgObjSize: 0,
      storageSize: 0,
      capped: false,
      nindexes: 0,
      totalIndexSize: 0,
      indexSizes: {}
    };

    try {
      stats = await this._collection.stats();
    } catch (err) { };

    return {
      name:           this.name,
      size:           (stats.storageSize || 0) + (stats.totalIndexSize || 0),
      dataSize:       stats.size,
      count:          stats.count,
      avgObjSize:     stats.avgObjSize || 0,
      storageSize:    stats.storageSize || 0,
      capped:         stats.capped,
      nIndexes:       stats.nindexes,
      totalIndexSize: stats.totalIndexSize || 0,
      indexSizes:     stats.indexSizes
    };
  }