Skip to content

Commit

Permalink
Update search (#67)
Browse files Browse the repository at this point in the history
* added update method

* added update doc
  • Loading branch information
kailash-bitpack committed May 11, 2023
1 parent b7870d8 commit ac43bc7
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@merokudao/dapp-store-registry",
"version": "0.1.43",
"version": "0.1.44",
"description": "The dApp Store registry for MerokuDAO dAapp Store",
"repository": {
"type": "git",
Expand Down
17 changes: 17 additions & 0 deletions src/handlers/opensearch-handlers/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,21 @@ export class OpensearchRequest {
public async attachAliasName(index: string, alias: string) {
return this.opensearchClient.indices.putAlias({ index, name: alias });
}

/**
* insert a new doc to database
* @param index index name
* @param body doc
* @returns response
*/
public async updateDoc(index: string, body: any): Promise<any> {
const id = body.id;
delete body.id;
return this.opensearchClient.update({
index,
id,
body: { doc: body },
refresh: true
});
}
}
26 changes: 26 additions & 0 deletions src/lib/v1/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,4 +279,30 @@ export class DappStoreRegistryV1 {
data: res && res.map(rs => rs._source)
};
};


/**
* update dapp to index, when new app is registered on dapp store
* @param name
* @param dapp
* @param org
* @returns acknowledge
*/
public async updateDapp(
payload: AddDappPayload
): Promise<StandardResponse> {
const { dapp } = payload;
/**
* have to add if any action have to do onchain
*/
await this.opensearchApis.updateDoc(searchRegistry.alias, {
id: dapp.dappId,
...dapp
});
return {
status: 200,
message: ["success"]
};
}

}

0 comments on commit ac43bc7

Please sign in to comment.