V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
jinnietsai
V2EX  ›  Python

Python 里面如何使用 Mongdb 创建一个固定的集合。

  •  
  •   jinnietsai · 2014-03-08 00:03:24 +08:00 · 3455 次点击
    这是一个创建于 3711 天前的主题,其中的信息可能已经有所发展或是发生改变。
    3 条回复    1970-01-01 08:00:00 +08:00
    nimoqu
        1
    nimoqu  
       2014-03-08 13:26:41 +08:00
    这是的固定集合指的是什么呢?
    jinnietsai
        2
    jinnietsai  
    OP
       2014-03-08 22:13:32 +08:00
    @nimoqu 就是指集合大小是固定的,比如只允许插入五十条记录,当满了以后再次向集合里面插入的时候就不允许了。之前在网络上搜索时通过创建fixedcollection,但是自己试了一下,不行。
    lix
        3
    lix  
       2014-03-09 10:40:51 +08:00
    MongoDB里有Capped Collection, 可以指定大小, 但会用新数据替换旧数据. 在插入之前先查询一下有多少记录, 达到你的上限了就提示不能插入了不就行了?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1477 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 16:49 · PVG 00:49 · LAX 09:49 · JFK 12:49
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.