Search Results

Search found 2 results on 1 pages for 'zmg'.

Page 1/1 | 1 

  • MongoDB - proper use of collections?

    - by zmg
    In Mongo my understanding is that you can have databases and collections. I'm working on a social-type app that will have blogs and comments (among other things) and had previously be using MySQL and pretty heavy partitioning in an attempt to limit possible concurrency issues. With MySQL I've stuffed all my user data into a _user database with several tables to further partition the data (blogs, pages, etc). My immediate reaction with Mongo would be to create a 'users' database with one collection per user. In this way user 'zach' blog entries would go into the 'zach' collection with associated comments and such becoming sub-objects in the same collection. Basically like dynamically creating one table per user in MySQL, but apparently without the complexity and limitations that might impose. Of course since I haven't really used Mongo before I'm having trouble gauging the (ahem..) quality of this idea and the potential problems it might cause down the road. I'd like user data to be treated a lot like a users directory in a *nix environment where user created/non-shared (mostly) gets put into one place (currently with MySQL that would be the appname_users as mentioned above). Most of the users data will be specific to the users page(s). Some of the user data which is queried across all site users (searchable user profiles) is currently kept in a separate database/table and I expect things like this could be put into a appname_system database and be broken up into collections and/or application specific databases (appname_profiles). Anyway, since the available documentation on this is currently a little thin and my experience is extremely limited I thought I might find a little guidance from someone with a better working understanding of the system. On the plus side I'd really already been attempting to treat MySQL as a schema-less document-store and doing this with Mongo seems much more intuitive/sane/rational so I'm really looking forward to getting started. Thanks, Zach

    Read the article

  • Mongodb update: how to check if an update succeeds or fails?

    - by zmg
    I think the title pretty much says it all. I'm working with Mongodb in PHP using the pecl driver. My updates are working great, but I'd like to build some error checking into my funciton(s). I've tried using lastError() in a pretty simple function: function system_db_update_object($query, $values, $database, $collection) { $connection = new Mongo(); $collection = $connection->$database->$collection; $connection->$database->resetError(); //Added for debugging $collection->update( $query, array('$set' => $values)); //$errorArray = $connection->$database->lastError(); var_dump($connection->$database->lastError());exit; // Var dump and /Exit/ } But pretty much regardless of what I try to update (whether it exists or not) I get these same basic results: array(4) { ["err"]=> NULL ["updatedExisting"]=> bool(true) ["n"]=> float(1) ["ok"]=> float(1) } Any help or direction would be greatly appreciated.

    Read the article

1