File size: 789 Bytes
57cf043
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from sqlalchemy import (
    ForeignKey,
    Integer,
)
from sqlalchemy.orm import Mapped, relationship, mapped_column
from components.dbo.models.base import Base


class DatasetDocument(Base):
    """
    Отношение многие ко многим между документами и датасетами.
    """

    __tablename__ = "dataset_document"

    dataset_id: Mapped[int] = mapped_column(
        Integer, ForeignKey('dataset.id', ondelete='CASCADE'), index=True
    )
    document_id: Mapped[int] = mapped_column(
        Integer, ForeignKey('document.id', ondelete='CASCADE'), index=True
    )

    dataset: Mapped["Dataset"] = relationship("Dataset", back_populates='documents')
    document: Mapped["Document"] = relationship("Document", back_populates='datasets')