Esempio n. 1
0
class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    nickname = db.Column(db.String(15), unique=True)
    name = db.Column(db.String(30), nullable=False)
    username = db.Column(db.String(20), unique=True, nullable=False)
    email = db.Column(db.String(120), unique=True, nullable=False)
    password = db.Column(db.String(60), nullable=False)
    address = db.Column(db.String)
    orders = db.relationship('Order', backref=db.backref('user'), lazy=True)
    comments = db.relationship('Comment', backref=db.backref('user'), lazy=True)
    credit_cards = db.relationship('CreditCard', backref=db.backref('user'), lazy=True)
    cart = db.relationship('Cart', backref=db.backref('user'), lazy=True)

    def __repr__(self):
        return f"User( email: '{self.email}', username: '******', password: '******')"
Esempio n. 2
0
class Book(db.Model):
    isbn = db.Column(db.BigInteger, primary_key=True)
    title = db.Column(db.String(100), unique=True, nullable=False)
    date_pub = db.Column(db.String(100))
    genre = db.Column(db.String(100))
    rating = db.Column(db.Float)
    numRatings = db.Column(db.BigInteger)
    price = db.Column(db.Float)
    img = db.Column(db.String(100))
    pub_info = db.Column(db.Text)
    book_description = db.Column(db.Text)
    comments = db.relationship('Comment', backref=db.backref('book'), lazy=True)
    carts = db.relationship('CartItem', backref=db.backref('book'), lazy=True)

    def __repr__(self):
        return f"Book( titel: '{self.title}' )"
Esempio n. 3
0
class Cart(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    date = db.Column(db.Date)
    cart_items = db.relationship('CartItem', backref=db.backref('cart'), lazy=True)

    def __repr__(self):
        return f"ShoppingCart( cart_id: '{self.id}', user_id: '{self.user_id}')"
Esempio n. 4
0
class Author(db.Model):
    name = db.Column(db.String(100), primary_key=True)
    info = db.Column(db.Text, nullable=False)
    books = db.relationship('Book',
                            secondary=publish,
                            backref=db.backref('authors'))

    def __repr__(self):
        return f"Author( name: '{self.name}' )"
Esempio n. 5
0
class Author(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100),unique=True)
    info = db.Column(db.Text)
    img = db.Column(db.String(100))
    books = db.relationship('Book', secondary=author_book_relationship, backref=db.backref('authors'))

    def __repr__(self):
        return f"Author( name: '{self.name}' )"