database-namespace.d.ts 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*! firebase-admin v12.1.1 */
  2. /*!
  3. * Copyright 2021 Google Inc.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. import * as rtdb from '@firebase/database-types';
  18. import { App } from '../app';
  19. import { Database as TDatabase } from './database';
  20. /**
  21. * Gets the {@link firebase-admin.database#Database} service for the default
  22. * app or a given app.
  23. *
  24. * `admin.database()` can be called with no arguments to access the default
  25. * app's `Database` service or as `admin.database(app)` to access the
  26. * `Database` service associated with a specific app.
  27. *
  28. * `admin.database` is also a namespace that can be used to access global
  29. * constants and methods associated with the `Database` service.
  30. *
  31. * @example
  32. * ```javascript
  33. * // Get the Database service for the default app
  34. * var defaultDatabase = admin.database();
  35. * ```
  36. *
  37. * @example
  38. * ```javascript
  39. * // Get the Database service for a specific app
  40. * var otherDatabase = admin.database(app);
  41. * ```
  42. *
  43. * @param App - whose `Database` service to
  44. * return. If not provided, the default `Database` service will be returned.
  45. *
  46. * @returns The default `Database` service if no app
  47. * is provided or the `Database` service associated with the provided app.
  48. */
  49. export declare function database(app?: App): database.Database;
  50. export declare namespace database {
  51. /**
  52. * Type alias to {@link firebase-admin.database#Database}.
  53. */
  54. type Database = TDatabase;
  55. /**
  56. * Type alias to {@link https://firebase.google.com/docs/reference/js/v8/firebase.database.DataSnapshot | DataSnapshot}
  57. * type from the `@firebase/database-compat` package.
  58. */
  59. type DataSnapshot = rtdb.DataSnapshot;
  60. /**
  61. * Type alias to the {@link https://firebase.google.com/docs/reference/js/v8/firebase.database#eventtype | EventType}
  62. * type from the `@firebase/database-compat` package.
  63. */
  64. type EventType = rtdb.EventType;
  65. /**
  66. * Type alias to {@link https://firebase.google.com/docs/reference/js/v8/firebase.database.OnDisconnect | OnDisconnect}
  67. * type from the `@firebase/database-compat` package.
  68. */
  69. type OnDisconnect = rtdb.OnDisconnect;
  70. /**
  71. * Type alias to {@link https://firebase.google.com/docs/reference/js/v8/firebase.database.Query | Query}
  72. * type from the `@firebase/database-compat` package.
  73. */
  74. type Query = rtdb.Query;
  75. /**
  76. * Type alias to {@link https://firebase.google.com/docs/reference/js/v8/firebase.database.Reference | Reference}
  77. * type from the `@firebase/database-compat` package.
  78. */
  79. type Reference = rtdb.Reference;
  80. /**
  81. * Type alias to {@link https://firebase.google.com/docs/reference/js/v8/firebase.database.ThenableReference |
  82. * ThenableReference} type from the `@firebase/database-compat` package.
  83. */
  84. type ThenableReference = rtdb.ThenableReference;
  85. /**
  86. * {@link https://firebase.google.com/docs/reference/js/v8/firebase.database#enablelogging | enableLogging}
  87. * function from the `@firebase/database-compat` package.
  88. */
  89. const enableLogging: typeof rtdb.enableLogging;
  90. /**
  91. * {@link https://firebase.google.com/docs/reference/js/v8/firebase.database.ServerValue | ServerValue}
  92. * constant from the `@firebase/database-compat` package.
  93. */
  94. const ServerValue: rtdb.ServerValue;
  95. }