内置的方式来读取ouchdb文档的大小? [英] Built in way to read couchdb document size?

查看:38
本文介绍了内置的方式来读取ouchdb文档的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用ouchdb作为消息存储,并希望报告消息大小。

I'm experimenting with using couchdb as a message store and would like to report the message size.

理想情况下,读取_size属性会很好。最糟糕的是,我可以检查整个文档的JSON的字符串长度。我什至可能要使用大小作为查看键。

Ideally it would be nice to read a _size attribute. At worst I could check the string length of the entire document's JSON. I may even want to use the size as a view key.

您认为记录文档大小的最佳方法是什么?为什么认为这种方法是最佳的?

What do you think is the best way to record document size and why do you think that method is best?

推荐答案

您可以查看;

function (doc) {
    emit(doc._id, JSON.stringify(doc).length);
}

这篇关于内置的方式来读取ouchdb文档的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆