Skip to content

Commit

Permalink
docs unified snake_case and camelCase
Browse files Browse the repository at this point in the history
  • Loading branch information
silverqx committed Jul 15, 2023
1 parent 8ca7813 commit adbfa4c
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/database/migrations.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ Within both of these methods, you may use the TinyORM schema builder to expressi

} // namespace Migrations

Migration classes can be named in two formats, StudlyCase without the datetime prefix and snake_case with the datetime prefix. If the StudlyCase name is used then the `T_MIGRATION` macro must also be used in the migration class.
Migration classes can be named in two formats, StudlyCase without the datetime prefix and "snake_case" with the datetime prefix. If the StudlyCase name is used then the `T_MIGRATION` macro must also be used in the migration class.

Naming with the datetime prefix should look like this.

Expand Down
2 changes: 1 addition & 1 deletion docs/tinyorm/casts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Accessors are currently only used during the serialization by the [Appending Val

### Defining An Accessor

An accessor transforms a TinyORM attribute value when it is accessed (currently during serialization only by the [Appending Values](tinyorm/serialization.mdx#appending-values-to-json) feature). To define an accessor, create a protected method on your model to represent the accessible attribute. This method name should correspond to the "camel case" representation of the true underlying model attribute / database column when applicable.
An accessor transforms a TinyORM attribute value when it is accessed (currently during serialization only by the [Appending Values](tinyorm/serialization.mdx#appending-values-to-json) feature). To define an accessor, create a protected method on your model to represent the accessible attribute. This method name should correspond to the "camelCase" representation of the true underlying model attribute / database column when applicable.

In this example, we'll define an accessor for the `first_name` attribute. The accessor will automatically be called by TinyORM during serialization if the `first_name` attribute is defined in the `u_appends` data member set. All attribute accessor methods must return the `Orm::Tiny::Casts::Attribute`:

Expand Down
2 changes: 1 addition & 1 deletion docs/tinyorm/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ Let's examine a basic model class and discuss some of TinyORM's key conventions:

### Table Names

After glancing at the example above, you may have noticed that we did not tell TinyORM which database table corresponds to our `Flight` model. By convention, the "snake case", plural name of the class will be used as the table name unless another name is explicitly specified. So, in this case, TinyORM will assume the `Flight` model stores records in the `flights` table, while an `AirTrafficController` model would store records in an `air_traffic_controllers` table.
After glancing at the example above, you may have noticed that we did not tell TinyORM which database table corresponds to our `Flight` model. By convention, the "snake_case", plural name of the class will be used as the table name unless another name is explicitly specified. So, in this case, TinyORM will assume the `Flight` model stores records in the `flights` table, while an `AirTrafficController` model would store records in an `air_traffic_controllers` table.

If your model's corresponding database table does not fit this convention, you may manually specify the model's table name by defining the private `u_table` data member on the model:

Expand Down
6 changes: 3 additions & 3 deletions docs/tinyorm/relationships.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ If the parent model does not use `id` as its primary key, or you wish to find th
return belongsTo<User>("foreign_key", "owner_key");
}

The third `belongsTo` parameter is the relation name, if you pass it, the foreign key name will be determined from it. By convention, TinyORM will "snake case" this relation name and suffix it with a `_` followed by the name of the parent model's primary key column to generate foreign key, the `__func__` predefined identifier is ideal for this. The relation name is also used in BelongsTo's `associate` and `disassociate` methods:
The third `belongsTo` parameter is the relation name, if you pass it, the foreign key name will be determined from it. By convention, TinyORM will "snake_case" this relation name and suffix it with a `_` followed by the name of the parent model's primary key column to generate foreign key, the `__func__` predefined identifier is ideal for this. The relation name is also used in BelongsTo's `associate` and `disassociate` methods:

/*! Get the user that owns the phone. */
std::unique_ptr<BelongsTo<Phone, User>>
Expand Down Expand Up @@ -251,7 +251,7 @@ A one-to-many relationship is used to define relationships where a single model

#endif // POST_HPP

Remember, TinyORM will automatically determine the proper foreign key column for the `Comment` model. By convention, TinyORM will take the "snake case" name of the parent model and suffix it with `_id`. So, in this example, TinyORM will assume the foreign key column on the `Comment` model is `post_id`.
Remember, TinyORM will automatically determine the proper foreign key column for the `Comment` model. By convention, TinyORM will take the "snake_case" name of the parent model and suffix it with `_id`. So, in this example, TinyORM will assume the foreign key column on the `Comment` model is `post_id`.

Once the relationship method has been defined, we can access the `QVector<Related *>` of related comments by Model's `getRelationValue<Related, Container = QVector>` method:

Expand Down Expand Up @@ -346,7 +346,7 @@ If your parent model does not use `id` as its primary key, or you wish to find t
return belongsTo<Post>("foreign_key", "owner_key");
}

The third `belongsTo` parameter is the relation name, if you pass it, the foreign key name will be determined from it. By convention, TinyORM will "snake case" this relation name and suffix it with a `_` followed by the name of the parent model's primary key column to generate foreign key, the `__func__` predefined identifier is ideal for this. The relation name is also used in BelongsTo's `associate` and `disassociate` methods:
The third `belongsTo` parameter is the relation name, if you pass it, the foreign key name will be determined from it. By convention, TinyORM will "snake_case" this relation name and suffix it with a `_` followed by the name of the parent model's primary key column to generate foreign key, the `__func__` predefined identifier is ideal for this. The relation name is also used in BelongsTo's `associate` and `disassociate` methods:

/*! Get the post that owns the comment. */
std::unique_ptr<BelongsTo<Comment, Post>>
Expand Down
2 changes: 1 addition & 1 deletion docs/tinyorm/serialization.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ Occasionally, when converting models to vector, map, or JSON, you may wish to ad
}
};

If you would like the accessor to always be appended to your model's vector, map, and JSON representations, you may add the attribute name to the `u_appends` data member set of your model. Note that attribute names are typically referenced using their "snake case" serialized representation, even though the accessor's method name is defined using "camel case":
If you would like the accessor to always be appended to your model's vector, map, and JSON representations, you may add the attribute name to the `u_appends` data member set of your model. Note that attribute names are typically referenced using their "snake_case" serialized representation, even though the accessor's method name is defined using "camelCase":

#include <orm/tiny/model.hpp>

Expand Down

0 comments on commit adbfa4c

Please sign in to comment.