Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storage get count #3705

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

Akinpete
Copy link

Description:
This PR introduces the get and count methods to the FileStorage class. These methods enhance the file storage functionality by allowing retrieval of specific objects by their class and ID, and counting objects based on their class.

  • get(cls, id): Retrieves an object by its class and ID from the file storage.
  • count(cls=None): Counts the number of objects in storage, optionally filtering by class.

Changes Introduced:

  • Added get method:

    • Retrieves an object from the file storage based on the provided class and ID.

    • If the object exists, it returns the object; otherwise, it returns None.

  • Added count method:

    • Counts all objects in storage if no class is specified.

    • Counts objects of a specific class if a class is provided.

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.

1 participant