doc: option is pk not pk_factory (although pk_factory is probably a better name)

This commit is contained in:
Mike Dirolf 2010-03-23 14:35:50 -04:00
parent 6139c27df0
commit 3fdd8c3f7a
1 changed files with 10 additions and 10 deletions

View File

@ -192,19 +192,19 @@ generate _id values. If you want to control _id values or even their types,
using a PK factory lets you do so. using a PK factory lets you do so.
You can tell the Ruby Mongo driver how to create primary keys by passing in You can tell the Ruby Mongo driver how to create primary keys by passing in
the :pk_factory option to the Connection#db method. the :pk option to the Connection#db method.
db = Mongo::Connection.new.db('dbname', :pk_factory => MyPKFactory.new) db = Mongo::Connection.new.db('dbname', :pk => MyPKFactory.new)
A primary key factory object must respond to :create_pk, which should take a A primary key factory object must respond to :create_pk, which should
hash and return a hash which merges the original hash with any primary key take a hash and return a hash which merges the original hash with any
fields the factory wishes to inject. primary key fields the factory wishes to inject.
NOTE: if the object already has a primary key, the factory should not inject NOTE: if the object already has a primary key, the factory should not
a new key; this means that the object may already exist in the database. inject a new key; this means that the object may already exist in the
The idea here is that whenever a record is inserted, database. The idea here is that whenever a record is inserted, the
the :pk_factory object's +create_pk+ method will be called and :pk object's +create_pk+ method will be called and the new hash
the new hash returned will be inserted. returned will be inserted.
Here is a sample primary key factory, taken from the tests: Here is a sample primary key factory, taken from the tests: