Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""LICENSE
2Copyright 2020 Hermann Krumrey <hermann@krumreyh.com>
4This file is part of jerrycan.
6jerrycan is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation, either version 3 of the License, or
9(at your option) any later version.
11jerrycan is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
16You should have received a copy of the GNU General Public License
17along with jerrycan. If not, see <http://www.gnu.org/licenses/>.
18LICENSE"""
20from jerrycan.base import db
21from jerrycan.db.ModelMixin import ModelMixin
24class IDModelMixin(ModelMixin):
25 """
26 A mixin class that specifies a couple of methods all database
27 models should implement.
28 Includes an automatically incrementing ID.
29 """
31 id = db.Column(
32 db.Integer, primary_key=True, nullable=False, autoincrement=True
33 )
34 """
35 The ID is the primary key of the table and increments automatically
36 """
38 def __hash__(self) -> int:
39 """
40 Creates a hash so that the model objects can be used as keys
41 :return: None
42 """
43 return hash(self.id)