User Tools

Site Tools


tutorials:kamailio-and-mongodb

This is an old revision of the document!


Kamailio and MongoDB

Kamailio Database

The use command in mongodb client mongo creates the database if it doesn't exit:

# mongo
> use kamailio

To display the databases, you can use:

> show dbs

Note that a database is not shown by the above command if it is empty – you need to add some records to it.

Version Table

Kamailio uses version table to check if the structure of a database table has the structure version the C code expects.

A table is MongoDB is named collection. To create the collection version, do:

> db.createCollection("version")

List the existing collections in the current database:

> show collections
system.indexes
version
> 

Version Table Records

Add the records for the other Kamailio tables you are going to use. Some examples:

> db.getCollection("version").insert({table_name: "subscriber", table_version: NumberInt(6) })

> db.getCollection("version").insert({table_name: "location", table_version: NumberInt(8) })

> db.getCollection("version").insert({table_name: "presentity", table_version: NumberInt(4) })

> db.getCollection("version").insert({table_name: "watchers", table_version: NumberInt(3) })

db.getCollection("version").insert({table_name: "active_watchers", table_version: NumberInt(11) })

Other Tables

MongoDB doesn't have a schema definition for documents stored in a collection.

tutorials/kamailio-and-mongodb.1441740452.txt.gz · Last modified: 2015/09/08 21:27 by miconda