@shisyamo4131/air-firebase-v2-client-adapter 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +34 -0
  2. package/package.json +7 -1
package/index.js CHANGED
@@ -69,6 +69,40 @@ class ClientAdapter {
69
69
  return ClientAdapter.firestore;
70
70
  }
71
71
 
72
+ /**
73
+ * 指定されたドキュメントIDからFirestoreのドキュメント参照を取得します。
74
+ * - コンバーターを適用したDocumentReferenceを返します。
75
+ * - このメソッドはFireModelクラスから静的に呼び出されることを想定しています。
76
+ *
77
+ * @param {Object} args - パラメータオブジェクト
78
+ * @param {string} args.docId - ドキュメントID(必須)
79
+ * @param {string|null} [args.prefix=null] - パスのプレフィックス(任意)
80
+ * @returns {DocumentReference} Firestoreのドキュメント参照
81
+ * @throws {Error} `docId` が指定されていない場合
82
+ */
83
+ getDocRef({ docId, prefix = null } = {}) {
84
+ if (!docId) {
85
+ throw new ClientAdapterError(ERRORS.VALIDATION_MISSING_DOC_ID);
86
+ }
87
+
88
+ try {
89
+ const collectionPath = this.constructor.getCollectionPath(prefix);
90
+ const colRef = collection(
91
+ ClientAdapter.firestore,
92
+ collectionPath
93
+ ).withConverter(this.constructor.converter());
94
+
95
+ return doc(colRef, docId);
96
+ } catch (err) {
97
+ if (err instanceof ClientAdapterError) {
98
+ throw err;
99
+ } else {
100
+ this._outputErrorConsole("getDocRef", err);
101
+ throw new ClientAdapterError(ERRORS.SYSTEM_UNKNOWN_ERROR);
102
+ }
103
+ }
104
+ }
105
+
72
106
  /**
73
107
  * Assigns an autonumber to the instance using a Firestore transaction.
74
108
  * - Retrieves the current autonumber doc from the `Autonumbers` collection.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shisyamo4131/air-firebase-v2-client-adapter",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "client adapter for FireModel",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -23,6 +23,12 @@
23
23
  "type": "git",
24
24
  "url": "https://github.com/shisyamo4131/air-firebase-v2-client-adapter.git"
25
25
  },
26
+ "scripts": {
27
+ "dev:publish": "npm version prerelease --preid=dev && npm publish --tag dev",
28
+ "release:patch": "npm version patch && npm publish",
29
+ "release:minor": "npm version minor && npm publish",
30
+ "release:major": "npm version major && npm publish"
31
+ },
26
32
  "publishConfig": {
27
33
  "access": "public"
28
34
  },