Giter VIP home page Giter VIP logo

mongo-fuse's Introduction

mongo-fuse

mongo-fuse is a virtual file system which represents MongoDB collections as folders, and documents as editable json files. This allows you to use regular unix toolchain for working with mongodb. For example, you can edit mongo docs with vim or emacs (or even sed, nano or libreoffice), search docs with grep, navigate databases with either your favourite shell, or something like mc or ranger.

This project was written for fun during a 24-hours hackathon in July 2012.

Installation

Checkout sources, then in the project folder run:

$ pip install .

or, if you don't have pip installed:

$ easy_install .

You might need root privilegies if you don't use virtualenv (though it's much better to start using virtualenv).

Basic usage

To start having fun with mongo-fuse, we need to mount virtual folder that will be representing mongo server:

$ mkdir -p /tmp/fusetest
$ mongofuse /tmp/fusetest

By default, your local mongodb instance (localhost:27017) will be mounted. To change this, pass optional --db argument.

That' it! Now we can navigate to the mounted folder. Top level subfolders are mongo databases:

$ cd /tmp/fusetest
$ ls
blog          dbhasha       genericData        pcat      week5
classify      dbhashb       loadserverscripts  status    test-classify
clientAdmin   etlpy-stats   local              students  test-etlpy-titan
curationTool  etlpy-status  test

Under database, you'll find folders for collections:

$ ls pcat
products  products_bak  system.indexes

Finally, each collection folder contains number of json files, one file per doc:

$ ls pcat/products
507d95d5719dbef170f15bf9.json  507d95d5719dbef170f15bfc.json  507d95d5719dbef170f15bff.json
507d95d5719dbef170f15bfa.json  507d95d5719dbef170f15bfd.json  507d95d5719dbef170f15c00.json
507d95d5719dbef170f15bfb.json  507d95d5719dbef170f15bfe.json  507d95d5719dbef170f15c01.json

Each file is a plain text/json file, which can be viewed, edited, copied (and even deleted) just as any other normal text file:

$ head pcat/products/507d95d5719dbef170f15bf9.json

    {
        "_id": {
            "$oid": "507d95d5719dbef170f15bf9"
        },
        "for": [
            "ac3",
            "ac7",
            "ac9"
        ],
        "name": "AC3 Series Charger",

$ grep AC3 pcat/products/*
pcat/products/507d95d5719dbef170f15bf9.json:    "name": "AC3 Series Charger",
pcat/products/507d95d5719dbef170f15bfa.json:    "name": "AC3 Case Green",
pcat/products/507d95d5719dbef170f15bfc.json:    "name": "AC3 Case Black",
pcat/products/507d95d5719dbef170f15bfd.json:    "name": "AC3 Case Red",

Filtering

Collection can have thousands documents in it, and it would not be cool to see all of those. That's why mongofuse shows only few dozens of docs, but allows you to filter results by creating virtual folders. Here is how it works:

$ cd pcat/products
$ mkdir -p by_name/AC3
$ ls ./by_name/AC3

TODO: finish docs

mongo-fuse's People

Contributors

maori avatar osyvokon avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.