AirBnB_clone_v2 icon indicating copy to clipboard operation
AirBnB_clone_v2 copied to clipboard

Storage get count

Open Akinpete opened this issue 5 months ago • 0 comments

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.

Akinpete avatar Sep 19 '24 09:09 Akinpete