Darko Fabijan wrote this on September 21, 2010

Two beginner Mongo notes

Problem: mongod doesn’t start and the tail of /var/log/mongodb/mongod.log says :

Mon Sep 20 12:00:16 exception in initAndListen std::exception: old lock file, terminating

Solution: you somehow did not shut down the machine properly the last time. Remove the old lock file:

sudo rm /var/lib/mongodb/mongod.lock

And if you’re on Ubuntu, you can use the new Upstart syntax to start the process via the init.d script that the package from 10gen PPA provides:

sudo start|stop mongodb

Problem: given the following Mongoid document:

class Post
  include Mongoid::Document
  field :tags, :type => Array

you’d like to find all posts that contain a certain tag.

Solution: use any_in criteria. It may not be obvious from the docs, but it does apply to fields of type Array too:

Post.any_in(:tags => [t])
comments powered by Disqus

About Darko Fabijan

Rendered Text co-founder. Enjoys breaking new ground and exploring tools and ideas that make lives of developers interesting and productive. Nowadays has less time to write code but has great pleasure in discussing it with the team. He spends his free time cooking, hiking and indoor gardening.

Suggested Reads

Inject is a fundamental building block

Inject is one of the fundamental, and most versatile constructs available in functional languages. It can be used to implement map, select, max, all? and a bunch of other iteration related methods. Unfortunately, many programmers are not aware of its awesome powers. This article is here to improve this fact.


Rendered Text is a software company. For questions regarding Semaphore, please visit semaphoreci.com. Otherwise, feel free to get in touch any time by sending us an email.

Rendered Text
Svetozara Miletica 10
21000 Novi Sad