@chevre/domain
Version:
Chevre Domain Library for Node.js
36 lines (31 loc) • 991 B
text/typescript
// tslint:disable:no-console
import * as mongoose from 'mongoose';
const KILO_BYTES = 1024;
async function main() {
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
let storageStats;
// const stats = await mongoose.connection.db.collection('tasks')
// .stats({
// scale: KILO_BYTES * KILO_BYTES
// });
storageStats = (await mongoose.connection.db.collection('tasks')
.aggregate([{
$collStats: {
storageStats: {
scale: KILO_BYTES * KILO_BYTES
}
}
}])
.limit(1)
.toArray())
.at(0)?.storageStats;
console.log('scaleFactor:', storageStats.scaleFactor);
console.log('avgObjSize:', storageStats.avgObjSize);
console.log('count:', storageStats.count);
console.log('size:', storageStats.size);
}
main()
.then(() => {
console.log('success!');
})
.catch(console.error);