Skip to content

Grapes database: tips and tricks

jdcoffre edited this page Oct 1, 2014 · 2 revisions

##MongoDb configuration & check:

Currently Grapes is running with a MongoDb database. This Database installation is a prerequisite to Grapes installation (more information about Grapes installation here).

Grapes is using a single database in your MongoDb instance. The name of this database is defined in the configuration file of your Grapes installation (more information about Grapes installation here).

To make sure that Grapes is correctly plugged to MongoDb, you can verify heath-checks of the administration panel. One of them is dedicated to the database.

##Few MongoDb tips

Connection to MongoDb using mongo client

  > mongo
    use <grapes-db-name>

Then you can request the elements of the different collection using MongoShell. The documentation of MongoShell very good and availble here.

You can list the available Grapes collections using:

 db.getCollectionNames()

You can perform queries on database elements using fields names. Go in the code to get the data-model or display one element of the collection. Here is an example to display a random element of collection DbModule:

 db.DbModule.findOne()

As soon as you know the data-model you can perform the request you want. Here is an example to get all modules that have the version "1.0.0-special":

 db.DbModule.find({ version : "1.0.0-special" })
Clone this wiki locally