class User(UserMixin, db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(80), nullable=False) password = db.Column(db.String(80), nullable=False) shopping_list_items = db.relationship('GroceryItem', secondary='shopping_list_table', back_populates='users_shopping_list')
class User(UserMixin, db.Model): '''User model''' id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(80), nullable=False) password = db.Column(db.String(150), nullable=False) items = db.relationship('GroceryItem', secondary='shopping_cart', back_populates='users')
class User(db.Model, UserMixin): """User Item""" id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(80), nullable=False) password = db.Column(db.String(80), nullable=False) created_by_id = db.Column(db.Integer, db.ForeignKey('user.id')) created_by = db.relationship('User') shopping_list_items = db.relationship('GroceryItem', secondary='shopping_list', back_populates='user_items')
class User(db.Model, UserMixin): """User model.""" __tablename__ = 'user' id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(80), nullable=False) password = db.Column(db.String(256), nullable=False) shopping_list_items = db.relationship( 'GroceryItem', secondary='user_groceryitem_association')
class GroceryStore(db.Model): """Grocery Store model.""" id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(80), nullable=False) address = db.Column(db.String(200), nullable=False) items = db.relationship('GroceryItem', back_populates='store') created_by_id = db.Column(db.Integer, db.ForeignKey('user.id')) created_by = db.relationship('User')
class User(db.Model, UserMixin): """User model""" id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(80), nullable=False, unique=True) password = db.Column(db.String(200), nullable=False) shopping_list_items = db.relationship('GroceryItem', secondary='user_item', back_populates='created_by')
class User(UserMixin, db.Model): """ User Model """ id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(80), nullable=False, unique=True) password = db.Column(db.String(200), nullable=False) shopping_list_items = db.relationship("GroceryItem", secondary="shopping_list")
class User(db.Model, UserMixin): """User model.""" id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(50), nullable=False) password = db.Column(db.String(150), nullable=False) shopping_list_items = db.relationship('GroceryItem', secondary='shopping_list', back_populates = 'shopping_list') def __str__(self): return f'{self.username}'
class GroceryStore(db.Model): """Grocery Store model.""" id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(80), nullable=False) address = db.Column(db.String(200), nullable=False) items = db.relationship('GroceryItem', back_populates='store') def __str__(self): return str(self.title)
class User(db.Model, UserMixin): """User model.""" id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(42), nullable=False) password = db.Column(db.String(80), nullable=False) shopping_list_items = db.relationship( "GroceryItem", secondary="shopping_list", back_populates="shopping_lists" )
class GroceryStore(db.Model): """Grocery Store model.""" id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(80), nullable=False) address = db.Column(db.String(200), nullable=False) items = db.relationship('GroceryItem', back_populates='store') created_by = db.relationship("User") created_by_id = db.Column(db.Integer, db.ForeignKey("user.id")) def __str__(self): return f"{self.title}"
class User(UserMixin, db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(80), nullable=False, unique=True) password = db.Column(db.String(200), nullable=False) shopping_list_items = db.relationship('GroceryItem', secondary='shopping_list', back_populates='shopping_list_user') def __repr__(self): return f'<User: {self.username}>'
class User(UserMixin, db.Model): """User model.""" id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(80), nullable=False, unique=True) password = db.Column(db.String(200), nullable=False) # Add many-to-many relationship between User and GroceryItem shopping_list_items = db.relationship( 'GroceryItem', secondary='shopping_list', back_populates='users_who_shopped') # Display username for created_by credits def __repr__(self): return f'<User: {self.username}>'
class GroceryStore(db.Model): """Grocery Store model.""" id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(80), nullable=False) address = db.Column(db.String(200), nullable=False) items = db.relationship('GroceryItem', back_populates='store') # Include string representations for the drop-down menu def __str__(self): return f'<Grocery Store: {self.title}>' def __repr__(self): return f'<Grocery Store: {self.title}>'
class User(UserMixin, db.Model): """Grocery Store model.""" id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(50), nullable=False) password = db.Column(db.String(50), nullable=False) cart_items = db.relationship('GroceryItem', secondary='shopping_cart', back_populates='users_cart') def __str__(self): return f'{self.username}' def __repr__(self): return f'{self.username}'
class GroceryStore(db.Model): """Grocery Store model.""" id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(80), nullable=False) address = db.Column(db.String(200), nullable=False) items = db.relationship('GroceryItem', back_populates='store') # Add created_by field to see the user who added the store created_by_id = db.Column(db.Integer, db.ForeignKey('user.id')) created_by = db.relationship('User') # Include string representations for the drop-down menu def __str__(self): return f'<Grocery Store: {self.title}>' def __repr__(self): return f'<Grocery Store: {self.title}>'
class User(db.Model, UserMixin): """User Model""" id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(50), nullable=False) password = db.Column(db.String(50), nullable=False) shopping_list_items = db.relationship( "GroceryItem", secondary="shopping_list_table", back_populates="user_shopping_list", ) shopping_list_table = db.Table( "shopping_list_table", db.Column("grocery_item", db.Integer, db.ForeignKey("grocery_item.id")), db.Column("user", db.Integer, db.ForeignKey("user.id")), )
class GroceryItem(db.Model): """Grocery Item model.""" id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(80), nullable=False) price = db.Column(db.Float(precision=2), nullable=False) category = db.Column(db.Enum(ItemCategory), default=ItemCategory.OTHER) photo_url = db.Column(URLType) store_id = db.Column(db.Integer, db.ForeignKey('grocery_store.id'), nullable=False) store = db.relationship('GroceryStore', back_populates='items')
class GroceryItem(db.Model): """Grocery Item model.""" id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(80), nullable=False) price = db.Column(db.Float(precision=2), nullable=False) category = db.Column(db.Enum(ItemCategory), default=ItemCategory.OTHER) photo_url = db.Column(URLType) store_id = db.Column( db.Integer, db.ForeignKey('grocery_store.id'), nullable=False) store = db.relationship('GroceryStore', back_populates='items') # Add created_by field to see the user who added the item created_by_id = db.Column(db.Integer, db.ForeignKey('user.id')) created_by = db.relationship('User') # Add many-to-many relationship between User and GroceryItem users_who_shopped = db.relationship( 'User', secondary='shopping_list', back_populates='shopping_list_items')
class GroceryItem(db.Model): """Grocery Item model.""" id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(80), nullable=False) price = db.Column(db.Float(precision=2), nullable=False) category = db.Column(db.Enum(ItemCategory), default=ItemCategory.OTHER) photo_url = db.Column(URLType) store_id = db.Column(db.Integer, db.ForeignKey('grocery_store.id'), nullable=False) store = db.relationship('GroceryStore', back_populates='items') created_by = db.relationship("User") created_by_id = db.Column(db.Integer, db.ForeignKey("user.id")) user_shopping_list = db.relationship("User", secondary="shopping_list_table", back_populates="shopping_list_items")
class GroceryItem(db.Model): """Grocery Item model.""" __tablename__ = 'grocery_item' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(80), nullable=False) price = db.Column(db.Float(precision=2), nullable=False) category = db.Column(db.Enum(ItemCategory), default=ItemCategory.OTHER) photo_url = db.Column(URLType) store_id = db.Column(db.Integer, db.ForeignKey('grocery_store.id'), nullable=False) store = db.relationship('GroceryStore', back_populates='items') created_by_id = db.Column(db.Integer, db.ForeignKey('user.id')) created_by = db.relationship('User') shopping_lists = db.relationship('User', secondary='user_groceryitem_association')
class GroceryItem(db.Model): """Grocery Item model.""" id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(80), nullable=False) price = db.Column(db.Float(precision=2), nullable=False) category = db.Column(db.Enum(ItemCategory), default=ItemCategory.OTHER) photo_url = db.Column(URLType) store_id = db.Column(db.Integer, db.ForeignKey('grocery_store.id'), nullable=False) store = db.relationship('GroceryStore', back_populates='items') """ Foreign Key column (to store the user’s id)""" created_by_id = db.Column(db.Integer, db.ForeignKey('user.id')) """ Relationship (to store the User object itself) """ created_by = db.relationship('User') customer = db.relationship("User", secondary="shopping_list")
class GroceryItem(db.Model): """Grocery Item model.""" id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(80), nullable=False) price = db.Column(db.Float(precision=2), nullable=False) category = db.Column(db.Enum(ItemCategory), default=ItemCategory.OTHER) photo_url = db.Column(URLType) store_id = db.Column(db.Integer, db.ForeignKey('grocery_store.id'), nullable=False) store = db.relationship('GroceryStore', back_populates='items') created_by_id = db.Column(db.Integer, db.ForeignKey('user.id')) created_by = db.relationship('User') users_cart = db.relationship('User', secondary='shopping_cart', back_populates='cart_items') def __str__(self): return f'<Item: {self.name}>' def __repr__(self): return f'<Item: {self.name}>'
class User(UserMixin, db.Model): """User model.""" id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(25), nullable=False) password = db.Column(db.String(80), nullable=False) shopping_list_items = db.relationship('GroceryItem')
class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(24), nullable=False, unique=True) password = db.column(db.String(80)) shopping_list_items = db.relationship('GroceryItem')