Skip to content

chore: rename mongodb client functions from [CRUD]Entity to [CRUD]Metadata#480

Merged
zaeema-n merged 10 commits into
LDFLK:mainfrom
prdai-archive:fix/rename-mongo-crud-operations-340
May 21, 2026
Merged

chore: rename mongodb client functions from [CRUD]Entity to [CRUD]Metadata#480
zaeema-n merged 10 commits into
LDFLK:mainfrom
prdai-archive:fix/rename-mongo-crud-operations-340

Conversation

@prdai

@prdai prdai commented May 13, 2026

Copy link
Copy Markdown
Contributor

summary

renames the crud operations for mongodb from using entity to metadata, as they were in reality updating the metadata instead of the entity it self, and updates any references that was using the functions that was renamed.

validation

cd opengin/core-api/db/repository/mongo
go test .

fixes: #340

Copilot AI review requested due to automatic review settings May 13, 2026 07:49
@CLAassistant

CLAassistant commented May 13, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request renames the CRUD operations in the MongoDB repository from 'Entity' to 'Metadata' (e.g., CreateMetadata, ReadMetadata) to better reflect their specific purpose. The changes span the repository implementation, the metadata handler, and associated tests. Feedback was provided to update the accompanying function comments to ensure they consistently refer to 'metadata' instead of 'entity' or 'attributes,' maintaining clarity throughout the codebase.

Comment thread opengin/core-api/db/repository/mongo/mongodb_client.go Outdated
Comment thread opengin/core-api/db/repository/mongo/mongodb_client.go Outdated
Comment thread opengin/core-api/db/repository/mongo/mongodb_client.go Outdated
Comment thread opengin/core-api/db/repository/mongo/mongodb_client.go Outdated
Comment thread opengin/core-api/db/repository/mongo/metadata_handler.go Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR renames the MongoDB repository CRUD-style methods from *Entity to *Metadata to better reflect that the MongoDB collection is being used for metadata persistence rather than full entity lifecycle management (per Issue #340).

Changes:

  • Renamed CreateEntity/ReadEntity/UpdateEntity/DeleteEntity to CreateMetadata/ReadMetadata/UpdateMetadata/DeleteMetadata in the MongoDB repository.
  • Updated the Mongo metadata handler to call the renamed repository methods.
  • Updated the MongoDB repository tests to use the renamed methods.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
opengin/core-api/db/repository/mongo/mongodb_client.go Renames MongoRepository CRUD methods to *Metadata variants.
opengin/core-api/db/repository/mongo/mongodb_client_test.go Updates tests to call the renamed *Metadata methods.
opengin/core-api/db/repository/mongo/metadata_handler.go Updates metadata handler to use ReadMetadata/CreateMetadata/UpdateMetadata.
Comments suppressed due to low confidence (1)

opengin/core-api/db/repository/mongo/mongodb_client.go:79

  • Renaming these methods removes the previous CreateEntity/ReadEntity/UpdateEntity/DeleteEntity APIs, but there are still non-test call sites in the repo that reference the old names (e.g., opengin/core-api/engine/graph_metadata_manager.go and opengin/core-api/cmd/server/service.go). As-is, the core-api build will fail due to missing methods. Either update all remaining call sites in this PR or keep backwards-compatible wrappers (deprecated) that forward the old method names to the new *Metadata methods.
func (repo *MongoRepository) CreateMetadata(ctx context.Context, entity *pb.Entity) (*mongo.InsertOneResult, error) {

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread opengin/core-api/db/repository/mongo/mongodb_client.go Outdated
Comment thread opengin/core-api/db/repository/mongo/mongodb_client_test.go Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread opengin/core-api/db/repository/mongo/mongodb_client.go
Comment thread opengin/core-api/db/repository/mongo/metadata_handler.go Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

opengin/core-api/db/repository/mongo/mongodb_client_test.go:214

  • The test name/commentary in this section still refers to deleting an “entity”, but the repository call is now DeleteMetadata and is specifically deleting the metadata document. Consider updating the wording to avoid implying the underlying graph/entity is deleted.
	// Create entity
	_, err = testRepo.CreateMetadata(testCtx, entity)
	assert.NoError(t, err)

	// Delete entity
	result, err := testRepo.DeleteMetadata(testCtx, entityID)
	assert.NoError(t, err)
	assert.Equal(t, int64(1), result.DeletedCount)

	// Verify entity is deleted
	_, err = testRepo.ReadMetadata(testCtx, entityID)
	assert.Error(t, err) // Should return an error since entity doesn't exist

Comment thread opengin/core-api/db/repository/mongo/mongodb_client_test.go Outdated
Comment thread opengin/core-api/db/repository/mongo/mongodb_client_test.go Outdated
Comment thread opengin/core-api/db/repository/mongo/mongodb_client.go

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

opengin/core-api/db/repository/mongo/mongodb_client_test.go:214

  • This test now exercises DeleteMetadata/ReadMetadata, but the test name and the doc comment block above still reference "DeleteEntity" and deleting an "entity". Please update the test name and the doc comment so they match the renamed API and describe that only metadata is being deleted from MongoDB.
	// Delete metadata
	result, err := testRepo.DeleteMetadata(testCtx, entityID)
	assert.NoError(t, err)
	assert.Equal(t, int64(1), result.DeletedCount)

	// Verify metadata is deleted
	_, err = testRepo.ReadMetadata(testCtx, entityID)
	assert.Error(t, err) // Should return an error since metadata doesn't exist

Comment thread opengin/core-api/db/repository/mongo/mongodb_client_test.go
Comment thread opengin/core-api/cmd/server/service.go Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comment thread opengin/core-api/db/repository/mongo/mongodb_client_test.go
Comment thread opengin/core-api/engine/graph_metadata_manager.go
@zaeema-n

Copy link
Copy Markdown
Member

Hi @prdai. One of your workflows is failing due to a deprecated key in the workflow file. I have now fixed that and merged it into main. Please rebase your code from main, I will then rerun your workflows.

prdai and others added 10 commits May 21, 2026 11:32
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@prdai prdai force-pushed the fix/rename-mongo-crud-operations-340 branch from 5f979fc to 77e2bc9 Compare May 21, 2026 06:02
@prdai

prdai commented May 21, 2026

Copy link
Copy Markdown
Contributor Author

hi @zaeema-n, i rebased with upstream main, let me know if there is anything else to be done, thanks!

@zaeema-n

Copy link
Copy Markdown
Member

LGTM! Thank you for your contribution @prdai!

@zaeema-n zaeema-n merged commit 21c8094 into LDFLK:main May 21, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rename functions in mongodb_client.go

4 participants