Coder Social home page Coder Social logo

airbnb_clone's Introduction

AirBnB clone - The console

Repository for the AirBnB clone project! (The Holberton B&B)

HBnB

Description

The console

The first piece is to manipulate a powerful storage system. This storage engine will give us an abstraction between “My object” and “How they are stored and persisted”. This means: from your console code (the command interpreter itself) and from the front-end and RestAPI you will build later, you won’t have to pay attention (take care) of how your objects are stored.

This abstraction will also allow you to change the type of storage easily without updating all of your codebase.

The console will be a tool to validate this storage engine

  • Create your data model
  • Manage (create, update, destroy, etc) objects via a console / command interpreter
  • Store and persist objects to a file (JSON file)

Requirements

  • All your files will be interpreted/compiled on Ubuntu 14.04 LTS using python3 (version 3.4.3)
  • All your files should end with a new line
  • Your code should use the PEP 8 style (version 1.7 or more)
  • All your files must be executable
  • All your modules should have a documentation
  • All your classes should have a documentation
  • All your functions (inside and outside a class) should have a documentation

Files and Directories

  • console.py file is the entry point of our command interpreter.
  • models directory will contain all classes used for the entire project.
    • base_model.py file is the base class of all our models. It contains common elements:
    • user.py
    • state.py
    • city.py
    • place.py
    • review.py
    • amenity.py
    • engine directory contain all storage classes (using the same prototype).
      • file_storage.py serializes instances to a JSON file and deserializes JSON file to instances
  • tests directory will contain all unit tests.

Use

To start the console, you only need to type: ./console.py

How to use the console?

  1. Start the console
  2. Write the desired command with its respective syntax

Available classes: BaseModel, User, Place, State, City, Amenity and Review

Command Syntax Description
create create <class> create a object
show show <class> <id> show an specific object
destroy destroy <class> <id> destroy an specific object
all all <class> show all objects by class
all all show all objects
update update <class> <attr_name> <new_value> update an object with the new values

Also, you can type the name of the class followed by the instruction, like this:

Command Syntax Description
all <class name>.all() show all objects by class
count <class name>.count() a counter of specific class
show <class name>.show(<id>) show an specific object
destroy <class name>.destroy(<id>) destroy an specific object
update <class name>.update(<id>, <attribute name>, <attribute value>) update an object with the new values
  1. Press the enter button

Examples:

  • Create a new User: (hbnb) create User
  • Show an user by id: (hbnb) show User fce12f8a
  • Destroy an user by id: (hbnb) destroy User fce12f8a
  • Show all the instances of the User class: (hbnb) all User
  • Show all the instances of all the classes: (hbnb) all
  • Show all the instances of the User class: (hbnb) User.all()
  • Print the number of instances of the User class: (hbnb) User.count()
  • Show user by id: (hbnb) User.show("246c227a")
  • Destroy user by id: (hbnb) User.destroy("246c227a")
  • Update User attributes by id: (hbnb) User.update("38f22813-2753-4d42-b37c-57a17f1e4f88", "first_name", "John")

Authors and Contributors

airbnb_clone's People

Contributors

juanmarcoscabezas avatar asokadev avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.