Skip to content

Schema

Objects representing a database schema.

Checkbox

Bases: PropertyObject

Defines the checkbox configuration for a database property.

Source code in src/notional/schema.py
189
190
191
192
class Checkbox(PropertyObject, type="checkbox"):
    """Defines the checkbox configuration for a database property."""

    checkbox: Any = {}

CreatedBy

Bases: PropertyObject

Defines the created-by configuration for a database property.

Source code in src/notional/schema.py
286
287
288
289
class CreatedBy(PropertyObject, type="created_by"):
    """Defines the created-by configuration for a database property."""

    created_by: Any = {}

CreatedTime

Bases: PropertyObject

Defines the created-time configuration for a database property.

Source code in src/notional/schema.py
280
281
282
283
class CreatedTime(PropertyObject, type="created_time"):
    """Defines the created-time configuration for a database property."""

    created_time: Any = {}

Date

Bases: PropertyObject

Defines the date configuration for a database property.

Source code in src/notional/schema.py
171
172
173
174
class Date(PropertyObject, type="date"):
    """Defines the date configuration for a database property."""

    date: Any = {}

DualPropertyRelation

Bases: PropertyRelation

Defines a dual-property relation configuration for a database property.

Source code in src/notional/schema.py
243
244
245
246
247
248
249
250
class DualPropertyRelation(PropertyRelation, type="dual_property"):
    """Defines a dual-property relation configuration for a database property."""

    class _NestedData(GenericObject):
        synced_property_name: Optional[str] = None
        synced_property_id: Optional[str] = None

    dual_property: _NestedData = _NestedData()

Email

Bases: PropertyObject

Defines the email configuration for a database property.

Source code in src/notional/schema.py
195
196
197
198
class Email(PropertyObject, type="email"):
    """Defines the email configuration for a database property."""

    email: Any = {}

Files

Bases: PropertyObject

Defines the files configuration for a database property.

Source code in src/notional/schema.py
183
184
185
186
class Files(PropertyObject, type="files"):
    """Defines the files configuration for a database property."""

    files: Any = {}

Formula

Bases: PropertyObject

Defines the formula configuration for a database property.

Source code in src/notional/schema.py
213
214
215
216
217
218
219
class Formula(PropertyObject, type="formula"):
    """Defines the formula configuration for a database property."""

    class _NestedData(GenericObject):
        expression: str = None

    formula: _NestedData = _NestedData()

Function

Bases: str, Enum

Standard aggregation functions.

Source code in src/notional/schema.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
class Function(str, Enum):
    """Standard aggregation functions."""

    COUNT = "count"
    COUNT_VALUES = "count_values"
    COUNT_PER_GROUP = "count_per_group"

    EMPTY = "empty"
    NOT_EMPTY = "not_empty"

    CHECKED = "checked"
    UNCHECKED = "unchecked"

    PERCENT_EMPTY = "percent_empty"
    PERCENT_NOT_EMPTY = "percent_not_empty"
    PERCENT_CHECKED = "percent_checked"
    PERCENT_PER_GROUP = "percent_per_group"

    AVERAGE = "average"
    MIN = "min"
    MAX = "max"
    MEDIAN = "median"
    RANGE = "range"
    SUM = "sum"

    DATE_RANGE = "date_range"
    EARLIEST_DATE = "earliest_date"
    LATEST_DATE = "latest_date"

    SHOW_ORIGINAL = "show_original"
    SHOW_UNIQUE = "show_unique"
    UNIQUE = "unique"

LastEditedBy

Bases: PropertyObject

Defines the last-edited-by configuration for a database property.

Source code in src/notional/schema.py
292
293
294
295
class LastEditedBy(PropertyObject, type="last_edited_by"):
    """Defines the last-edited-by configuration for a database property."""

    last_edited_by: Any = {}

LastEditedTime

Bases: PropertyObject

Defines the last-edited-time configuration for a database property.

Source code in src/notional/schema.py
298
299
300
301
class LastEditedTime(PropertyObject, type="last_edited_time"):
    """Defines the last-edited-time configuration for a database property."""

    last_edited_time: Any = {}

MultiSelect

Bases: PropertyObject

Defines the multi-select configuration for a database property.

Source code in src/notional/schema.py
156
157
158
159
160
161
162
class MultiSelect(PropertyObject, type="multi_select"):
    """Defines the multi-select configuration for a database property."""

    class _NestedData(GenericObject):
        options: List[SelectOption] = []

    multi_select: _NestedData = _NestedData()

Number

Bases: PropertyObject

Defines the number configuration for a database property.

Source code in src/notional/schema.py
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
class Number(PropertyObject, type="number"):
    """Defines the number configuration for a database property."""

    class _NestedData(GenericObject):
        format: NumberFormat = NumberFormat.NUMBER

        # leads to better error messages, see
        # https://github.com/pydantic/pydantic/issues/355
        @pydantic.validator("format", pre=True)
        def validate_enum_field(cls, field: str):
            return NumberFormat(field)

    number: _NestedData = _NestedData()

    @classmethod
    def __compose__(cls, format):
        """Create a `Number` object with the expected format."""
        return cls(number=cls._NestedData(format=format))

__compose__(format) classmethod

Create a Number object with the expected format.

Source code in src/notional/schema.py
123
124
125
126
@classmethod
def __compose__(cls, format):
    """Create a `Number` object with the expected format."""
    return cls(number=cls._NestedData(format=format))

NumberFormat

Bases: str, Enum

Available number formats in Notion.

Source code in src/notional/schema.py
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
class NumberFormat(str, Enum):
    """Available number formats in Notion."""

    NUMBER = "number"
    NUMBER_WITH_COMMAS = "number_with_commas"
    PERCENT = "percent"
    DOLLAR = "dollar"
    CANADIAN_DOLLAR = "canadian_dollar"
    EURO = "euro"
    POUND = "pound"
    YEN = "yen"
    RUBLE = "ruble"
    RUPEE = "rupee"
    WON = "won"
    YUAN = "yuan"
    REAL = "real"
    LIRA = "lira"
    RUPIAH = "rupiah"
    FRANC = "franc"
    HONG_KONG_DOLLAR = "hong_kong_dollar"
    NEW_ZEALAND_DOLLAR = "new_zealand_dollar"
    KRONA = "krona"
    NORWEGIAN_KRONE = "norwegian_krone"
    MEXICAN_PESO = "mexican_peso"
    RAND = "rand"
    NEW_TAIWAN_DOLLAR = "new_taiwan_dollar"
    DANISH_KRONE = "danish_krone"
    ZLOTY = "zloty"
    BAHT = "baht"
    FORINT = "forint"
    KORUNA = "koruna"
    SHEKEL = "shekel"
    CHILEAN_PESO = "chilean_peso"
    PHILIPPINE_PESO = "philippine_peso"
    DIRHAM = "dirham"
    COLOMBIAN_PESO = "colombian_peso"
    RIYAL = "riyal"
    RINGGIT = "ringgit"
    LEU = "leu"
    ARGENTINE_PESO = "argentine_peso"
    URUGUAYAN_PESO = "uruguayan_peso"

People

Bases: PropertyObject

Defines the people configuration for a database property.

Source code in src/notional/schema.py
177
178
179
180
class People(PropertyObject, type="people"):
    """Defines the people configuration for a database property."""

    people: Any = {}

PhoneNumber

Bases: PropertyObject

Defines the phone number configuration for a database property.

Source code in src/notional/schema.py
207
208
209
210
class PhoneNumber(PropertyObject, type="phone_number"):
    """Defines the phone number configuration for a database property."""

    phone_number: Any = {}

PropertyObject

Bases: TypedObject

Base class for Notion property objects.

Source code in src/notional/schema.py
90
91
92
93
94
class PropertyObject(TypedObject):
    """Base class for Notion property objects."""

    id: Optional[str] = None
    name: Optional[str] = None

PropertyRelation

Bases: TypedObject

Defines common configuration for a property relation.

Source code in src/notional/schema.py
222
223
224
225
class PropertyRelation(TypedObject):
    """Defines common configuration for a property relation."""

    database_id: UUID = None

Relation

Bases: PropertyObject

Defines the relation configuration for a database property.

Source code in src/notional/schema.py
253
254
255
256
class Relation(PropertyObject, type="relation"):
    """Defines the relation configuration for a database property."""

    relation: PropertyRelation = PropertyRelation()

RichText

Bases: PropertyObject

Defines the rich text configuration for a database property.

Source code in src/notional/schema.py
103
104
105
106
class RichText(PropertyObject, type="rich_text"):
    """Defines the rich text configuration for a database property."""

    rich_text: Any = {}

Rollup

Bases: PropertyObject

Defines the rollup configuration for a database property.

Source code in src/notional/schema.py
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
class Rollup(PropertyObject, type="rollup"):
    """Defines the rollup configuration for a database property."""

    class _NestedData(GenericObject):
        function: Function = Function.COUNT

        relation_property_name: Optional[str] = None
        relation_property_id: Optional[str] = None

        rollup_property_name: Optional[str] = None
        rollup_property_id: Optional[str] = None

        # leads to better error messages, see
        # https://github.com/pydantic/pydantic/issues/355
        @pydantic.validator("function", pre=True)
        def validate_enum_field(cls, field: str):
            return Function(field)

    rollup: _NestedData = _NestedData()

Select

Bases: PropertyObject

Defines the select configuration for a database property.

Source code in src/notional/schema.py
142
143
144
145
146
147
148
149
150
151
152
153
class Select(PropertyObject, type="select"):
    """Defines the select configuration for a database property."""

    class _NestedData(GenericObject):
        options: List[SelectOption] = []

    select: _NestedData = _NestedData()

    @classmethod
    def __compose__(cls, options):
        """Create a `Select` object from the list of `SelectOption`'s."""
        return cls(select=cls._NestedData(options=options))

__compose__(options) classmethod

Create a Select object from the list of SelectOption's.

Source code in src/notional/schema.py
150
151
152
153
@classmethod
def __compose__(cls, options):
    """Create a `Select` object from the list of `SelectOption`'s."""
    return cls(select=cls._NestedData(options=options))

SelectOption

Bases: GenericObject

Options for select & multi-select objects.

Source code in src/notional/schema.py
129
130
131
132
133
134
135
136
137
138
139
class SelectOption(GenericObject):
    """Options for select & multi-select objects."""

    name: str
    id: str = None
    color: str = Color.DEFAULT

    @classmethod
    def __compose__(cls, name, color=Color.DEFAULT):
        """Create a `SelectOption` object from the given name and color."""
        return cls(name=name, color=color)

__compose__(name, color=Color.DEFAULT) classmethod

Create a SelectOption object from the given name and color.

Source code in src/notional/schema.py
136
137
138
139
@classmethod
def __compose__(cls, name, color=Color.DEFAULT):
    """Create a `SelectOption` object from the given name and color."""
    return cls(name=name, color=color)

SinglePropertyRelation

Bases: PropertyRelation

Defines a single-property relation configuration for a database property.

Source code in src/notional/schema.py
228
229
230
231
232
233
234
235
236
237
238
239
240
class SinglePropertyRelation(PropertyRelation, type="single_property"):
    """Defines a single-property relation configuration for a database property."""

    single_property: Any = {}

    @classmethod
    def __compose__(cls, dbref):
        """Create a `single_property` relation using the target database reference.

        `dbref` must be either a string or UUID.
        """

        return Relation(relation=SinglePropertyRelation(database_id=dbref))

__compose__(dbref) classmethod

Create a single_property relation using the target database reference.

dbref must be either a string or UUID.

Source code in src/notional/schema.py
233
234
235
236
237
238
239
240
@classmethod
def __compose__(cls, dbref):
    """Create a `single_property` relation using the target database reference.

    `dbref` must be either a string or UUID.
    """

    return Relation(relation=SinglePropertyRelation(database_id=dbref))

Status

Bases: PropertyObject

Defines the status configuration for a database property.

Source code in src/notional/schema.py
165
166
167
168
class Status(PropertyObject, type="status"):
    """Defines the status configuration for a database property."""

    status: Any = {}

Title

Bases: PropertyObject

Defines the title configuration for a database property.

Source code in src/notional/schema.py
 97
 98
 99
100
class Title(PropertyObject, type="title"):
    """Defines the title configuration for a database property."""

    title: Any = {}

URL

Bases: PropertyObject

Defines the URL configuration for a database property.

Source code in src/notional/schema.py
201
202
203
204
class URL(PropertyObject, type="url"):
    """Defines the URL configuration for a database property."""

    url: Any = {}