Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • you must make sure the entity implements Replicable interface. Implement all methods with relevant info.
  • make sure the replication is triggered when saving and deleting. One thing to take into account is that the replication is not triggered if the save method is called something other than saveObject(Object) (replace Object with any name), because only the methods with that name are intercepted. (Similar with delete.) Another option is to publish an event, but the recommended way is the interceptor way.
  • make sure the entities are retrieved by an ReplicableProvider. The recommended way to do that is to create a separate ReplicableProvider implementation to implement the getReplicables method.
Mongo CLI

There are a bunch of useful commands to use from Mongo CLI (accessible by typing mongo in your favourite terminal).

  • show dbs
    prints out all databases.
  • show collections
    prints out all collections in a database (you'll need to use a_particular_database first).
  • db.entity.find()
    this will print out all documents in entity collection. Not very useful if there are many as it prints out just a few (you'll notice "has more" at the end).
  • db.entity.find({_id : /User.*/})
    db.entity.find({_id: { $regex: 'User.*', $options: 'i' } } )
    regular expression finder. Use your imagination to narrow your search.
    (first example may not work on CLI 2.0.7)
  • db.entity.find({ent:"user"})
    instead of regex you may find all entities of a particular type using ent field. This field is the java class name in lower case.
  • db.entity.find({type:"openacdskill", name:"German"})
    narrow the search by applying multiple "filters".
  • db.entity.drop()
    drop the entire entity collection.
  • db.entity.find({uid:"200"})
    find a particular user document. User names are held in the uid field.
  • db.entity.find({uid:"200"}).forEach(function (d) {printjson(d)})
    prints out a formatted version of the document. Pretty useful when looking at a single document. You can also use: db.entity.find({uid:"200"}).forEach(function (d) {printjson(d.prm)}) to see a formatted version of the prm field (permissions).
  • db.entity.find({uid:"200"}).forEach(function (d) {print("_id: "+ d._id +"; perms: "+d.prm)});
    print out just a few fields from a particular document

More: http://docs.mongodb.org/manual/reference/operators/