| 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 library gcloud.db; | 5 library gcloud.db; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 import 'dart:mirrors' as mirrors; | 9 import 'dart:mirrors' as mirrors; |
| 10 | 10 |
| 11 import 'common.dart' show Page, StreamFromPages; | 11 import 'common.dart' show Page, StreamFromPages; |
| 12 import 'service_scope.dart' as ss; | 12 import 'service_scope.dart' as ss; |
| 13 import 'datastore.dart' as datastore; | 13 import 'datastore.dart' as datastore; |
| 14 | 14 |
| 15 part 'src/db/annotations.dart'; | 15 part 'src/db/annotations.dart'; |
| 16 part 'src/db/db.dart'; | 16 part 'src/db/db.dart'; |
| 17 part 'src/db/models.dart'; | 17 part 'src/db/models.dart'; |
| 18 part 'src/db/model_db.dart'; | 18 part 'src/db/model_db.dart'; |
| 19 part 'src/db/model_db_impl.dart'; | 19 part 'src/db/model_db_impl.dart'; |
| 20 | 20 |
| 21 const Symbol _dbKey = #_gcloud.db; | 21 const Symbol _dbKey = #_gcloud.db; |
| 22 | 22 |
| 23 /// Access the [DatastoreDB] object available in the current service scope. | 23 /// Access the [DatastoreDB] object available in the current service scope. |
| 24 /// | 24 /// |
| 25 /// The returned object will be the one which was previously registered with | 25 /// The returned object will be the one which was previously registered with |
| 26 /// [registerDbService] within the current (or a parent) service scope. | 26 /// [registerDbService] within the current (or a parent) service scope. |
| 27 /// | 27 /// |
| 28 /// Accessing this getter outside of a service scope will result in an error. | 28 /// Accessing this getter outside of a service scope will result in an error. |
| 29 /// See the `package:gcloud/service_scope.dart` library for more information. |
| 29 DatastoreDB get dbService => ss.lookup(_dbKey); | 30 DatastoreDB get dbService => ss.lookup(_dbKey); |
| 30 | 31 |
| 31 /// Registers the [DatastoreDB] object within the current service scope. | 32 /// Registers the [DatastoreDB] object within the current service scope. |
| 32 /// | 33 /// |
| 33 /// The provided `db` object will be avilable via the top-level `db` getter. | 34 /// The provided `db` object will be avilable via the top-level `db` getter. |
| 34 /// | 35 /// |
| 35 /// Calling this function outside of a service scope will result in an error. | 36 /// Calling this function outside of a service scope will result in an error. |
| 36 /// Calling this function more than once inside the same service scope is not | 37 /// Calling this function more than once inside the same service scope is not |
| 37 /// allowed. | 38 /// allowed. |
| 38 void registerDbService(DatastoreDB db) { | 39 void registerDbService(DatastoreDB db) { |
| 39 ss.register(_dbKey, db); | 40 ss.register(_dbKey, db); |
| 40 } | 41 } |
| OLD | NEW |