(store, fn)
| 154 | } |
| 155 | |
| 156 | function collection(store, fn) { |
| 157 | var db = store._db; |
| 158 | |
| 159 | return getConnection(db).then(function (mdb) { |
| 160 | return new Promise(function(resolve, reject) { |
| 161 | mdb.collection(store.namespace, function (err, collection) { |
| 162 | if(err || !collection) { |
| 163 | error(err || new Error('Unable to get ' + store.namespace + ' collection')); |
| 164 | process.exit(1); |
| 165 | } |
| 166 | |
| 167 | if (fn) fn(null, collection); |
| 168 | resolve(collection); |
| 169 | }); |
| 170 | }); |
| 171 | }).catch(function (err) { |
| 172 | if (fn) fn(err); |
| 173 | throw err; |
| 174 | }); |
| 175 | } |
| 176 | |
| 177 | /** |
| 178 | * Returns a promise, or calls fn with the mongo collection served by this store |
no test coverage detected