| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of gcloud.db; | 5 part of gcloud.db; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * A function definition for transactional functions. | 8 * A function definition for transactional functions. |
| 9 * | 9 * |
| 10 * The function will be given a [Transaction] object which can be used to make | 10 * The function will be given a [Transaction] object which can be used to make |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 } | 240 } |
| 241 return propertyName; | 241 return propertyName; |
| 242 } | 242 } |
| 243 } | 243 } |
| 244 | 244 |
| 245 class DatastoreDB { | 245 class DatastoreDB { |
| 246 final datastore.Datastore datastore; | 246 final datastore.Datastore datastore; |
| 247 final ModelDB _modelDB; | 247 final ModelDB _modelDB; |
| 248 Partition _defaultPartition; | 248 Partition _defaultPartition; |
| 249 | 249 |
| 250 DatastoreDB(this.datastore, {ModelDB modelDB}) | 250 DatastoreDB(this.datastore, {ModelDB modelDB, Partition defaultPartition}) : |
| 251 : _modelDB = modelDB != null ? modelDB : new ModelDBImpl() { | 251 _modelDB = modelDB != null ? modelDB : new ModelDBImpl() { |
| 252 _defaultPartition = new Partition(null); | 252 _defaultPartition = |
| 253 defaultPartition != null ? defaultPartition : new Partition(null); |
| 253 } | 254 } |
| 254 | 255 |
| 255 /** | 256 /** |
| 256 * The [ModelDB] used to serialize/deserialize objects. | 257 * The [ModelDB] used to serialize/deserialize objects. |
| 257 */ | 258 */ |
| 258 ModelDB get modelDB => _modelDB; | 259 ModelDB get modelDB => _modelDB; |
| 259 | 260 |
| 260 /** | 261 /** |
| 261 * Gets the empty key using the default [Partition]. | 262 * Gets the empty key using the default [Partition]. |
| 262 * | 263 * |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 | 374 |
| 374 Future<List<Model>> _lookupHelper( | 375 Future<List<Model>> _lookupHelper( |
| 375 DatastoreDB db, List<Key> keys, | 376 DatastoreDB db, List<Key> keys, |
| 376 {datastore.Transaction datastoreTransaction}) { | 377 {datastore.Transaction datastoreTransaction}) { |
| 377 var entityKeys = keys.map(db.modelDB.toDatastoreKey).toList(); | 378 var entityKeys = keys.map(db.modelDB.toDatastoreKey).toList(); |
| 378 return db.datastore.lookup(entityKeys, transaction: datastoreTransaction) | 379 return db.datastore.lookup(entityKeys, transaction: datastoreTransaction) |
| 379 .then((List<datastore.Entity> entities) { | 380 .then((List<datastore.Entity> entities) { |
| 380 return entities.map(db.modelDB.fromDatastoreEntity).toList(); | 381 return entities.map(db.modelDB.fromDatastoreEntity).toList(); |
| 381 }); | 382 }); |
| 382 } | 383 } |
| OLD | NEW |