mirror of
https://github.com/silverqx/TinyORM.git
synced 2026-02-11 12:59:16 -06:00
changed position of friend and using BaseModel
Changed in all models and the documentation was updated too.
This commit is contained in:
@@ -50,11 +50,10 @@ Before you start defining relationship methods, you have to declare a model clas
|
||||
|
||||
class User final : public BaseModel<User, Phone>
|
||||
{
|
||||
public:
|
||||
friend BaseModel;
|
||||
|
||||
using BaseModel::BaseModel;
|
||||
|
||||
public:
|
||||
/*! Get the phone associated with the user. */
|
||||
std::unique_ptr<Relation<User, Phone>>
|
||||
phone()
|
||||
@@ -103,11 +102,10 @@ A one-to-one relationship is a very basic type of database relationship. For exa
|
||||
|
||||
class User final : public BaseModel<User, Phone>
|
||||
{
|
||||
public:
|
||||
friend BaseModel;
|
||||
|
||||
using BaseModel::BaseModel;
|
||||
|
||||
public:
|
||||
/*! Get the phone associated with the user. */
|
||||
std::unique_ptr<Relation<User, Phone>>
|
||||
phone()
|
||||
@@ -160,11 +158,10 @@ So, we can access the `Phone` model from our `User` model. Next, let's define a
|
||||
|
||||
class Phone final : public BaseModel<Phone, User>
|
||||
{
|
||||
public:
|
||||
friend BaseModel;
|
||||
|
||||
using BaseModel::BaseModel;
|
||||
|
||||
public:
|
||||
/*! Get the user that owns the phone. */
|
||||
std::unique_ptr<Relation<Phone, User>>
|
||||
user()
|
||||
@@ -238,11 +235,10 @@ A one-to-many relationship is used to define relationships where a single model
|
||||
|
||||
class Post final : public BaseModel<Post, Comment>
|
||||
{
|
||||
public:
|
||||
friend BaseModel;
|
||||
|
||||
using BaseModel::BaseModel;
|
||||
|
||||
public:
|
||||
/*! Get the comments for the blog post. */
|
||||
std::unique_ptr<Relation<Post, Comment>>
|
||||
comments()
|
||||
@@ -307,11 +303,10 @@ Now that we can access all of a post's comments, let's define a relationship to
|
||||
|
||||
class Comment final : public BaseModel<Comment, Post>
|
||||
{
|
||||
public:
|
||||
friend BaseModel;
|
||||
|
||||
using BaseModel::BaseModel;
|
||||
|
||||
public:
|
||||
/*! Get the post that owns the comment. */
|
||||
std::unique_ptr<Relation<Comment, Post>>
|
||||
post()
|
||||
@@ -397,11 +392,10 @@ For example, imagine a blog application in which a `User` model has many associa
|
||||
|
||||
class User final : public BaseModel<User, Post>
|
||||
{
|
||||
public:
|
||||
friend BaseModel;
|
||||
|
||||
using BaseModel::BaseModel;
|
||||
|
||||
public:
|
||||
/*! Get all of the posts for the user. */
|
||||
std::unique_ptr<Relation<User, Post>>
|
||||
posts()
|
||||
@@ -517,11 +511,10 @@ When accessing TinyORM relationships by BaseModel's `getRelationValue` method, t
|
||||
|
||||
class Book final : public BaseModel<Book, Author>
|
||||
{
|
||||
public:
|
||||
friend BaseModel;
|
||||
|
||||
using BaseModel::BaseModel;
|
||||
|
||||
public:
|
||||
/*! Get the author that wrote the book. */
|
||||
std::unique_ptr<Relation<Book, Author>>
|
||||
author()
|
||||
@@ -598,11 +591,10 @@ Sometimes you might want to always load some relationships when retrieving a mod
|
||||
|
||||
class Book final : public BaseModel<Book, Author>
|
||||
{
|
||||
public:
|
||||
friend BaseModel;
|
||||
|
||||
using BaseModel::BaseModel;
|
||||
|
||||
public:
|
||||
/*! Get the author that wrote the book. */
|
||||
std::unique_ptr<Relation<Book, Author>>
|
||||
author()
|
||||
@@ -677,11 +669,10 @@ For example, when a `Comment` model is updated, you may want to automatically "t
|
||||
|
||||
class Comment final : public BaseModel<Comment, Post>
|
||||
{
|
||||
public:
|
||||
friend BaseModel;
|
||||
|
||||
using BaseModel::BaseModel;
|
||||
|
||||
public:
|
||||
/*! Get the post that owns the comment. */
|
||||
std::unique_ptr<Relation<Comment, Post>>
|
||||
post()
|
||||
|
||||
@@ -35,7 +35,6 @@ Let's examine a basic model class and discuss some of TinyORM's key conventions:
|
||||
|
||||
class Flight final : public Orm::Tiny::BaseModel<Flight>
|
||||
{
|
||||
public:
|
||||
friend BaseModel;
|
||||
|
||||
using BaseModel::BaseModel;
|
||||
@@ -54,7 +53,6 @@ If your model's corresponding database table does not fit this convention, you m
|
||||
|
||||
class Flight final : public Orm::Tiny::BaseModel<Flight>
|
||||
{
|
||||
public:
|
||||
friend BaseModel;
|
||||
using BaseModel::BaseModel;
|
||||
|
||||
@@ -72,7 +70,6 @@ TinyORM will also assume that each model's corresponding database table has a pr
|
||||
|
||||
class Flight final : public Orm::Tiny::BaseModel<Flight>
|
||||
{
|
||||
public:
|
||||
friend BaseModel;
|
||||
using BaseModel::BaseModel;
|
||||
|
||||
@@ -87,7 +84,6 @@ In addition, TinyORM assumes that the primary key is an incrementing integer val
|
||||
|
||||
class Flight final : public Orm::Tiny::BaseModel<Flight>
|
||||
{
|
||||
public:
|
||||
friend BaseModel;
|
||||
using BaseModel::BaseModel;
|
||||
|
||||
@@ -112,7 +108,6 @@ By default, TinyOrm expects `created_at` and `updated_at` columns to exist on yo
|
||||
|
||||
class Flight final : public Orm::Tiny::BaseModel<Flight>
|
||||
{
|
||||
public:
|
||||
friend BaseModel;
|
||||
using BaseModel::BaseModel;
|
||||
|
||||
@@ -127,7 +122,6 @@ If you need to customize the format of your model's timestamps, set the private
|
||||
|
||||
class Flight final : public Orm::Tiny::BaseModel<Flight>
|
||||
{
|
||||
public:
|
||||
friend BaseModel;
|
||||
using BaseModel::BaseModel;
|
||||
|
||||
@@ -142,7 +136,6 @@ If you need to customize the names of the columns used to store the timestamps,
|
||||
|
||||
class Flight final : public Orm::Tiny::BaseModel<Flight>
|
||||
{
|
||||
public:
|
||||
friend BaseModel;
|
||||
using BaseModel::BaseModel;
|
||||
|
||||
@@ -164,7 +157,6 @@ By default, all TinyOrm models will use the default database connection that is
|
||||
|
||||
class Flight final : public Orm::Tiny::BaseModel<Flight>
|
||||
{
|
||||
public:
|
||||
friend BaseModel;
|
||||
using BaseModel::BaseModel;
|
||||
|
||||
|
||||
@@ -8,11 +8,10 @@
|
||||
class FilePropertyProperty final :
|
||||
public Orm::Tiny::BaseModel<FilePropertyProperty, TorrentPreviewableFileProperty>
|
||||
{
|
||||
public:
|
||||
friend BaseModel;
|
||||
|
||||
using BaseModel::BaseModel;
|
||||
|
||||
public:
|
||||
/*! Get the previewable file that owns the file property. */
|
||||
std::unique_ptr<
|
||||
Orm::Tiny::Relations::Relation<FilePropertyProperty, TorrentPreviewableFileProperty>>
|
||||
|
||||
@@ -5,9 +5,7 @@
|
||||
|
||||
class Setting final : public Orm::Tiny::BaseModel<Setting>
|
||||
{
|
||||
public:
|
||||
friend BaseModel;
|
||||
|
||||
using BaseModel::BaseModel;
|
||||
|
||||
private:
|
||||
|
||||
@@ -16,11 +16,10 @@ using Orm::WithItem;
|
||||
class Tag final : public Orm::Tiny::BaseModel<Tag, Torrent, TagProperty, Tagged>
|
||||
//class Tag final : public BaseModel<Tag, Torrent, TagProperty, Pivot>
|
||||
{
|
||||
public:
|
||||
friend BaseModel;
|
||||
|
||||
using BaseModel::BaseModel;
|
||||
|
||||
public:
|
||||
/*! Get torrents that belong to the tag. */
|
||||
std::unique_ptr<Relation<Tag, Torrent>>
|
||||
torrents()
|
||||
|
||||
@@ -7,13 +7,11 @@ using Orm::Tiny::Relations::BasePivot;
|
||||
|
||||
class Tagged final : public BasePivot<Tagged>
|
||||
{
|
||||
public:
|
||||
friend BaseModel;
|
||||
friend BasePivot;
|
||||
|
||||
using BasePivot::BasePivot;
|
||||
|
||||
private:
|
||||
// TODO add belongsToMany overload, which will not take table argument and obtains a table name from Model::getTable, Eloquent is doing this in the BelongsToMany::resolveTableName() method silverqx
|
||||
/*! Indicates if the ID is auto-incrementing. */
|
||||
// bool u_incrementing = true;
|
||||
|
||||
@@ -7,12 +7,9 @@ using Orm::Tiny::BaseModel;
|
||||
|
||||
class TagProperty final : public BaseModel<TagProperty>
|
||||
{
|
||||
public:
|
||||
friend BaseModel;
|
||||
|
||||
using BaseModel::BaseModel;
|
||||
|
||||
private:
|
||||
/*! The table associated with the model. */
|
||||
QString u_table {"tag_properties"};
|
||||
|
||||
|
||||
@@ -23,13 +23,13 @@ class Torrent final :
|
||||
public BaseModel<Torrent, TorrentPreviewableFile, TorrentPeer, Tag, Pivot>
|
||||
// public BaseModel<Torrent, TorrentPreviewableFile, TorrentPeer, Tag, Tagged>
|
||||
{
|
||||
public:
|
||||
friend BaseModel;
|
||||
using BaseModel::BaseModel;
|
||||
|
||||
public:
|
||||
/*! The "type" of the primary key ID. */
|
||||
using KeyType = quint64;
|
||||
|
||||
using BaseModel::BaseModel;
|
||||
// explicit Torrent(const QVector<Orm::AttributeItem> &attributes = {});
|
||||
|
||||
/*! Get the previewable files associated with the torrent. */
|
||||
|
||||
@@ -12,11 +12,10 @@ class TorrentEager final :
|
||||
public Orm::Tiny::BaseModel<TorrentEager, TorrentPreviewableFileEager,
|
||||
TorrentPeerEager_NoRelations>
|
||||
{
|
||||
public:
|
||||
friend BaseModel;
|
||||
|
||||
using BaseModel::BaseModel;
|
||||
|
||||
public:
|
||||
/*! Get the previewable files associated with the torrent. */
|
||||
std::unique_ptr<
|
||||
Orm::Tiny::Relations::Relation<TorrentEager, TorrentPreviewableFileEager>>
|
||||
|
||||
@@ -10,11 +10,10 @@
|
||||
class TorrentEager_Failed final :
|
||||
public Orm::Tiny::BaseModel<TorrentEager_Failed, TorrentPreviewableFileEager>
|
||||
{
|
||||
public:
|
||||
friend BaseModel;
|
||||
|
||||
using BaseModel::BaseModel;
|
||||
|
||||
public:
|
||||
/*! Get the previewable files associated with the torrent. */
|
||||
std::unique_ptr<
|
||||
Orm::Tiny::Relations::Relation<TorrentEager_Failed, TorrentPreviewableFileEager>>
|
||||
|
||||
@@ -7,11 +7,10 @@
|
||||
|
||||
class TorrentPeer final : public Orm::Tiny::BaseModel<TorrentPeer, Torrent>
|
||||
{
|
||||
public:
|
||||
friend BaseModel;
|
||||
|
||||
using BaseModel::BaseModel;
|
||||
|
||||
public:
|
||||
/*! Get the torrent that owns the torrent peer. */
|
||||
std::unique_ptr<
|
||||
Orm::Tiny::Relations::Relation<TorrentPeer, Torrent>>
|
||||
|
||||
@@ -8,11 +8,10 @@
|
||||
class TorrentPeerEager final :
|
||||
public Orm::Tiny::BaseModel<TorrentPeerEager, TorrentEager>
|
||||
{
|
||||
public:
|
||||
friend BaseModel;
|
||||
|
||||
using BaseModel::BaseModel;
|
||||
|
||||
public:
|
||||
/*! Get the torrent that owns the torrent peer. */
|
||||
std::unique_ptr<
|
||||
Orm::Tiny::Relations::Relation<TorrentPeerEager, TorrentEager>>
|
||||
|
||||
@@ -6,12 +6,9 @@
|
||||
class TorrentPeerEager_NoRelations final :
|
||||
public Orm::Tiny::BaseModel<TorrentPeerEager_NoRelations>
|
||||
{
|
||||
public:
|
||||
friend BaseModel;
|
||||
|
||||
using BaseModel::BaseModel;
|
||||
|
||||
private:
|
||||
/*! The table associated with the model. */
|
||||
QString u_table {"torrent_peers"};
|
||||
|
||||
|
||||
@@ -10,11 +10,10 @@ class TorrentPreviewableFile final :
|
||||
public Orm::Tiny::BaseModel<TorrentPreviewableFile, Torrent,
|
||||
TorrentPreviewableFileProperty>
|
||||
{
|
||||
public:
|
||||
friend BaseModel;
|
||||
|
||||
using BaseModel::BaseModel;
|
||||
|
||||
public:
|
||||
/*! Get the torrent that owns the previewable file. */
|
||||
std::unique_ptr<
|
||||
Orm::Tiny::Relations::Relation<TorrentPreviewableFile, Torrent>>
|
||||
|
||||
@@ -9,11 +9,10 @@ class TorrentPreviewableFileEager final :
|
||||
public Orm::Tiny::BaseModel<TorrentPreviewableFileEager,
|
||||
TorrentPreviewableFilePropertyEager>
|
||||
{
|
||||
public:
|
||||
friend BaseModel;
|
||||
|
||||
using BaseModel::BaseModel;
|
||||
|
||||
public:
|
||||
/*! Get the file property associated with the previewable file. */
|
||||
std::unique_ptr<
|
||||
Orm::Tiny::Relations::Relation<TorrentPreviewableFileEager,
|
||||
|
||||
@@ -9,11 +9,10 @@ class TorrentPreviewableFileProperty final :
|
||||
public Orm::Tiny::BaseModel<TorrentPreviewableFileProperty,
|
||||
TorrentPreviewableFile>
|
||||
{
|
||||
public:
|
||||
friend BaseModel;
|
||||
|
||||
using BaseModel::BaseModel;
|
||||
|
||||
public:
|
||||
/*! Get the previewable file that owns the file property. */
|
||||
std::unique_ptr<
|
||||
Orm::Tiny::Relations::Relation<TorrentPreviewableFileProperty,
|
||||
|
||||
@@ -6,12 +6,9 @@
|
||||
class TorrentPreviewableFilePropertyEager final :
|
||||
public Orm::Tiny::BaseModel<TorrentPreviewableFilePropertyEager>
|
||||
{
|
||||
public:
|
||||
friend BaseModel;
|
||||
|
||||
using BaseModel::BaseModel;
|
||||
|
||||
private:
|
||||
/*! The table associated with the model. */
|
||||
QString u_table {"torrent_previewable_file_properties"};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user