Skip to content

Commit

Permalink
fix(engine): set the correct names
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammadhonarvar committed Sep 2, 2024
1 parent 5a25ae2 commit 076fa3e
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions packages/engine/src/alwatr-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,19 @@ export class AlwatrStore {
/**
* Checks if a store file with the given ID exists.
*
* @param id - The ID of the store file to check.
* @param storeId - The ID of the store file to check.
* @returns `true` if the store file exists, `false` otherwise.
* @example
* ```typescript
* if (!alwatrStore.exists('user1/profile')) {
* if (!alwatrStore.hasStore('user1/profile')) {
* alwatrStore.defineDocument(...)
* }
* ```
*/
exists(id: StoreFileId): boolean {
const id_ = getStoreId(id);
hasStore(storeId: StoreFileId): boolean {
const id_ = getStoreId(storeId);
const exists = this.rootDb__.itemExists(id_);
logger.logMethodFull?.('exists', id_, exists);
logger.logMethodFull?.('hasStore', id_, exists);
return exists;
}

Expand Down Expand Up @@ -330,13 +330,13 @@ export class AlwatrStore {
* @param id_ The unique identifier of the store file.
* @example
* ```typescript
* alwatrStore.unload({name: 'user-list', region: Region.Secret});
* alwatrStore.exists({name: 'user-list', region: Region.Secret}); // true
* alwatrStore.unloadStore({name: 'user-list', region: Region.Secret});
* alwatrStore.hasStore({name: 'user-list', region: Region.Secret}); // true
* ```
*/
unload(id: StoreFileId): void {
const id_ = getStoreId(id);
logger.logMethodArgs?.('unload', id_);
unloadStore(storeId: StoreFileId): void {
const id_ = getStoreId(storeId);
logger.logMethodArgs?.('unloadStore', id_);
const ref = this.cacheReferences__[id_];
if (ref === undefined) return;
if (ref.hasUnprocessedChanges_ === true) {
Expand All @@ -352,19 +352,19 @@ export class AlwatrStore {
* If the file is not unloaded, it will be unloaded first.
* You don't need to await this method to complete unless you want to make sure the file is deleted on disk.
*
* @param id_ The ID of the file to delete.
* @param storeId The ID of the file to delete.
* @returns A Promise that resolves when the file is deleted.
* @example
* ```typescript
* alwatrStore.remove({name: 'user-list', region: Region.Secret});
* alwatrStore.exists({name: 'user-list', region: Region.Secret}); // false
* alwatrStore.removeStore({name: 'user-list', region: Region.Secret});
* alwatrStore.hasStore({name: 'user-list', region: Region.Secret}); // false
* ```
*/
async remove(id: StoreFileId): Promise<void> {
const id_ = getStoreId(id);
logger.logMethodArgs?.('remove', id_);
async removeStore(storeId: StoreFileId): Promise<void> {
const id_ = getStoreId(storeId);
logger.logMethodArgs?.('removeStore', id_);
if (!this.rootDb__.itemExists(id_)) {
logger.accident('doc', 'document_not_found', id_);
logger.accident('removeStore', 'document_not_found', id_);
throw new Error('document_not_found', {cause: id_});
}
const ref = this.cacheReferences__[id_];
Expand All @@ -382,7 +382,7 @@ export class AlwatrStore {
await unlink(resolve(this.config__.rootPath, path));
}
catch (error) {
logger.error('deleteFile', 'remove_file_failed', error, {id, path});
logger.error('removeStore', 'remove_file_failed', error, {id: storeId, path});
}
}

Expand Down Expand Up @@ -443,10 +443,10 @@ export class AlwatrStore {
*/
protected async storeChanged_<T extends JsonifiableObject>(from: DocumentReference<T> | CollectionReference<T>): Promise<void> {
logger.logMethodArgs?.('storeChanged__', from.id);
const rev = from.getStoreMetadata().rev;
const rev = from.getStoreMeta().rev;
try {
await this.writeContext__(from.path, from.getFullContext_());
if (rev === from.getStoreMetadata().rev) {
if (rev === from.getStoreMeta().rev) {
// Context not changed during saving
from.hasUnprocessedChanges_ = false;
}
Expand Down

0 comments on commit 076fa3e

Please sign in to comment.