Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed readme

  • Loading branch information...
commit 4295cd5d8301df1f5bf9251f16ac62d5fd32673c 1 parent a116c09
Christian Amor Kvalheim christkv authored

Showing 1 changed file with 33 additions and 38 deletions. Show diff stats Hide diff stats

  1. +33 38 Readme.md
71 Readme.md
Source Rendered
@@ -100,30 +100,30 @@ Defining your own primary key factory allows you to generate your own series of
100 100
101 101 Simple example below
102 102
103   - // Custom factory (need to provide a 12 byte array);
104   - CustomPKFactory = function() {}
105   - CustomPKFactory.prototype = new Object();
106   - CustomPKFactory.createPk = function() {
107   - return new ObjectID("aaaaaaaaaaaa");
108   - }
109   -
110   - var p_client = new Db('integration_tests_20', new Server("127.0.0.1", 27017, {}), {'pk':CustomPKFactory});
111   - p_client.open(function(err, p_client) {
112   - p_client.dropDatabase(function(err, done) {
113   - p_client.createCollection('test_custom_key', function(err, collection) {
114   - collection.insert({'a':1}, function(err, docs) {
115   - collection.find({'_id':new ObjectID("aaaaaaaaaaaa")}, function(err, cursor) {
116   - cursor.toArray(function(err, items) {
117   - test.assertEquals(1, items.length);
118   -
119   - // Let's close the db
120   - p_client.close();
  103 + // Custom factory (need to provide a 12 byte array);
  104 + CustomPKFactory = function() {}
  105 + CustomPKFactory.prototype = new Object();
  106 + CustomPKFactory.createPk = function() {
  107 + return new ObjectID("aaaaaaaaaaaa");
  108 + }
  109 +
  110 + var p_client = new Db('integration_tests_20', new Server("127.0.0.1", 27017, {}), {'pk':CustomPKFactory});
  111 + p_client.open(function(err, p_client) {
  112 + p_client.dropDatabase(function(err, done) {
  113 + p_client.createCollection('test_custom_key', function(err, collection) {
  114 + collection.insert({'a':1}, function(err, docs) {
  115 + collection.find({'_id':new ObjectID("aaaaaaaaaaaa")}, function(err, cursor) {
  116 + cursor.toArray(function(err, items) {
  117 + test.assertEquals(1, items.length);
  118 +
  119 + // Let's close the db
  120 + p_client.close();
  121 + });
121 122 });
122 123 });
123 124 });
124 125 });
125 126 });
126   - });
127 127
128 128 Strict mode
129 129 --------
@@ -132,28 +132,23 @@ Each database has an optional strict mode. If it is set then asking for a collec
132 132 that does not exist will return an Error object in the callback. Similarly if you
133 133 attempt to create a collection that already exists. Strict is provided for convenience.
134 134
135   - var error_client = new Db(
136   - 'integration_tests_',
137   - new Server("127.0.0.1", 27017, {auto_reconnect: false}),
138   - {strict:true});
139   - test.assertEquals(true, error_client.strict);
140   - error_client.open(function(err, error_client) {
141   - error_client.collection('does-not-exist', function(err, collection) {
142   - test.assertTrue(err instanceof Error);
143   - test.assertEquals("Collection does-not-exist does not exist. " +
144   - "Currently in strict mode.", err.message);
145   - });
  135 + var error_client = new Db('integration_tests_', new Server("127.0.0.1", 27017, {auto_reconnect: false}), {strict:true});
  136 + test.assertEquals(true, error_client.strict);
  137 +
  138 + error_client.open(function(err, error_client) {
  139 + error_client.collection('does-not-exist', function(err, collection) {
  140 + test.assertTrue(err instanceof Error);
  141 + test.assertEquals("Collection does-not-exist does not exist. Currently in strict mode.", err.message);
  142 + });
146 143
147   - error_client.createCollection('test_strict_access_collection',
148   - function(err, collection) {
149   - error_client.collection('test_strict_access_collection',
150   - function(err, collection) {
151   - test.assertTrue(collection instanceof Collection);
152   - // Let's close the db
153   - error_client.close();
  144 + error_client.createCollection('test_strict_access_collection', function(err, collection) {
  145 + error_client.collection('test_strict_access_collection', function(err, collection) {
  146 + test.assertTrue(collection instanceof Collection);
  147 + // Let's close the db
  148 + error_client.close();
  149 + });
154 150 });
155 151 });
156   - });
157 152
158 153 Documentation
159 154 ========

0 comments on commit 4295cd5

Please sign in to comment.
Something went wrong with that request. Please try again.