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