Skip to content

Commit

Permalink
docs renamed QVector to QList
Browse files Browse the repository at this point in the history
  • Loading branch information
silverqx committed Jul 2, 2024
1 parent 8e89a5a commit 4c031cd
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 46 deletions.
8 changes: 4 additions & 4 deletions docs/database/migrations.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1299,7 +1299,7 @@ Schema::table("users", [](Blueprint &table)
});
```
You may drop multiple columns from a table by passing a `QVector<QString>` of column names to the `dropColumns` method, the `dropColumns` method also provides parameter pack overload:
You may drop multiple columns from a table by passing a `QList<QString>` of column names to the `dropColumns` method, the `dropColumns` method also provides parameter pack overload:
```cpp
Schema::table("users", [](Blueprint &table)
Expand Down Expand Up @@ -1349,7 +1349,7 @@ Alternatively, you may create the index after defining the column. To do so, you
table.unique("email");
```
You may even pass a `QVector<QString>` of columns to an index method to create a compound (or composite) index:
You may even pass a `QList<QString>` of columns to an index method to create a compound (or composite) index:
```cpp
table.index({"account_id", "created_at"});
Expand Down Expand Up @@ -1415,7 +1415,7 @@ To drop an index, you must specify the index's name. By default, TinyORM automat
</APITable>
</div>
I may also drop indexes by a column name or column names for composite keys, if you pass a `QVector<QString>` of columns into a method that drops indexes, the conventional index name will be generated based on the table name, columns, and index type:
I may also drop indexes by a column name or column names for composite keys, if you pass a `QList<QString>` of columns into a method that drops indexes, the conventional index name will be generated based on the table name, columns, and index type:
```cpp
Schema::table("geo", [](Blueprint &table)
Expand Down Expand Up @@ -1498,7 +1498,7 @@ To drop a foreign key, you may use the `dropForeign` method, passing the name of
table.dropForeign("posts_user_id_foreign");
```
Alternatively, you may pass a `QVector<QString>` containing the column name that holds the foreign key to the `dropForeign` method. The `QVector` will be converted to a foreign key constraint name using TinyORM's constraint naming conventions:
Alternatively, you may pass a `QList<QString>` containing the column name that holds the foreign key to the `dropForeign` method. The `QList` will be converted to a foreign key constraint name using TinyORM's constraint naming conventions:
```cpp
table.dropForeign({"user_id"});
Expand Down
20 changes: 10 additions & 10 deletions docs/database/query-builder.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ user.value("email").toString();

#### Retrieving A List Of Column Values

If you would like to retrieve the `QVector<QVariant>` instance containing the values of a single column, you may use the `pluck` method. In this example, we'll retrieve a collection of user titles:
If you would like to retrieve the `QList<QVariant>` instance containing the values of a single column, you may use the `pluck` method. In this example, we'll retrieve a collection of user titles:

```cpp
#include <QDebug>
Expand Down Expand Up @@ -467,7 +467,7 @@ auto users = DB::table("users")
.get();
```
You may also pass a `QVector<Orm::WhereItem>` of conditions to the `where` function. Each `Orm::WhereItem` structure should contain the four arguments typically passed to the `where` method:
You may also pass a `QList<Orm::WhereItem>` of conditions to the `where` function. Each `Orm::WhereItem` structure should contain the four arguments typically passed to the `where` method:
```cpp
auto users = DB::table("users")
Expand Down Expand Up @@ -509,7 +509,7 @@ select * from users where votes > 100 or (name = "Abigail" and votes > 50)
```
### Condition Operator Overriding
The `where` method overload with a `QVector<Orm::WhereItem>` as the first argument joins conditions using the `and` operator by default:
The `where` method overload with a `QList<Orm::WhereItem>` as the first argument joins conditions using the `and` operator by default:
```cpp
auto users = DB::table("users")
Expand Down Expand Up @@ -608,15 +608,15 @@ auto files = DB::table("files")
**whereIn / whereNotIn / orWhereIn / orWhereNotIn**
The `whereIn` method verifies that a given column's value is contained within the given `QVector<QVariant>`:
The `whereIn` method verifies that a given column's value is contained within the given `QList<QVariant>`:
```cpp
auto users = DB::table("users")
->whereIn("id", {1, 2, 3})
.get();
```
The `whereNotIn` method verifies that the given column's value is not contained in the given `QVector<QVariant>`:
The `whereNotIn` method verifies that the given column's value is not contained in the given `QList<QVariant>`:
```cpp
auto users = DB::table("users")
Expand Down Expand Up @@ -710,7 +710,7 @@ auto users = DB::table("users")
.get();
```
You may also pass a `QVector<Orm::WhereColumnItem>` of column comparisons to the `whereColumn` method. These conditions will be joined using the `and` operator:
You may also pass a `QList<Orm::WhereColumnItem>` of column comparisons to the `whereColumn` method. These conditions will be joined using the `and` operator:
```cpp
auto users = DB::table("users")
Expand Down Expand Up @@ -956,7 +956,7 @@ DB::table("users")->insert({
<Link id='multi-insert-overload' />
You may insert several records at once by passing a `QVector<QString>` for column names as the first argument and `QVector<QVector<QVariant>>` for values as the second argument. Each `QVector<QVariant>` represents a record that should be inserted into the table. This overload is useful for multi-insert and allows to specify column names only once:
You may insert several records at once by passing a `QList<QString>` for column names as the first argument and `QList<QList<QVariant>>` for values as the second argument. Each `QList<QVariant>` represents a record that should be inserted into the table. This overload is useful for multi-insert and allows to specify column names only once:
```cpp
DB::table("users")->insert({"email", "votes"},
Expand All @@ -966,7 +966,7 @@ DB::table("users")->insert({"email", "votes"},
});
```
You may also insert several records at once by passing a `QVector<QVariantMap>`. Each `QVariantMap` represents a record that should be inserted into the table:
You may also insert several records at once by passing a `QList<QVariantMap>`. Each `QVariantMap` represents a record that should be inserted into the table:
```cpp
DB::table("users")->insert({
Expand Down Expand Up @@ -1026,7 +1026,7 @@ Row and column aliases will be used with the MySQL server >=8.0.19 instead of th
## Update Statements
In addition to inserting records into the database, the query builder can also update existing records using the `update` method. The `update` method, accepts a `QVector<Orm::UpdateItem>` of column and value pairs, indicating the columns to be updated and returns a `std::tuple<int, QSqlQuery>` . You may constrain the `update` query using `where` clauses:
In addition to inserting records into the database, the query builder can also update existing records using the `update` method. The `update` method, accepts a `QList<Orm::UpdateItem>` of column and value pairs, indicating the columns to be updated and returns a `std::tuple<int, QSqlQuery>` . You may constrain the `update` query using `where` clauses:
```cpp
auto [affected, query] = DB::table("users")
Expand Down Expand Up @@ -1066,7 +1066,7 @@ DB::table("users")->decrement<int>("votes");
DB::table("users")->decrement("votes", 5.2); // float or double type
```
You may also specify additional columns to update during the operation as a `QVector<Orm::UpdateItem>`:
You may also specify additional columns to update during the operation as a `QList<Orm::UpdateItem>`:
```cpp
DB::table("users")->increment("votes", 1, {{"name", "John"}});
Expand Down
32 changes: 16 additions & 16 deletions docs/tinyorm/collections.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ keywords: [c++ orm, orm, collections, collection, model, tinyorm]

The `Orm::Tiny::Types::ModelsCollection` is specialized container which provides a fluent, convenient wrapper for working with vector of models. All TinyORM methods that return more than one model result, will return instances of the `ModelsCollection` class, including results retrieved via the `get` method or methods that return relationships like the `getRelation` and `getRelationValue`.

The `ModelsCollection` class extends `QVector<Model>`, so it naturally inherits dozens of methods used to work with the underlying vector of TinyORM models. Be sure to review the [`QList`](https://doc.qt.io/qt/qlist.html) documentation to learn all about these helpful methods!
The `ModelsCollection` class extends `QList<Model>`, so it naturally inherits dozens of methods used to work with the underlying vector of TinyORM models. Be sure to review the [`QList`](https://doc.qt.io/qt/qlist.html) documentation to learn all about these helpful methods!

:::info
The `ModelsCollection` template parameter can be declared only with the model type or a model type pointer, it also can't be `const` and can't be a reference. It's constrained using the `DerivedCollectionModel` concept.
:::

You can iterate over the `ModelsCollection` the same way as over the `QVector`:
You can iterate over the `ModelsCollection` the same way as over the `QList`:

```cpp
using Models::User;
Expand Down Expand Up @@ -50,7 +50,7 @@ The `ModelsCollection<Model>` is returning from the Models' methods like `get`,

#### Collection Conversion

While most TinyORM collection methods return a new instance of `ModelsCollection`, the `modelKeys`, `mapWithKeys`, and `pluck` methods return a base QVector or std unordered/map instances. Likewise, one of the `map` methods overload returns the `QVector<T>`.
While most TinyORM collection methods return a new instance of `ModelsCollection`, the `modelKeys`, `mapWithKeys`, and `pluck` methods return a base QList or std unordered/map instances. Likewise, one of the `map` methods overload returns the `QList<T>`.

### Creating Collections

Expand All @@ -71,10 +71,10 @@ ModelsCollection<User *> userPointers {
};
```

The `ModelsCollection<Model>` is implicitly convertible and assignable from the `QVector<Model>`:
The `ModelsCollection<Model>` is implicitly convertible and assignable from the `QList<Model>`:

```cpp
QVector<User> usersVector {
QList<User> usersVector {
{{"name", "Kate"}, {"votes", 150}},
{{"name", "John"}, {"votes", 200}},
};
Expand Down Expand Up @@ -174,7 +174,7 @@ For a better understanding of the following examples, many of the variable decla
The `all` method returns a copy of the underlying vector represented by the collection:

```cpp
QVector<User> = users.all();
QList<User> = users.all();
```

:::note
Expand Down Expand Up @@ -541,10 +541,10 @@ auto usersAdded = users.map([](User &&userCopy)
*/
```

The second `map` overload allows to return the `QVector<T>`:
The second `map` overload allows to return the `QList<T>`:

```cpp
QVector<quint64> usersAdded = users.map<quint64>([](User &&userCopy)
QList<quint64> usersAdded = users.map<quint64>([](User &&userCopy)
{
const auto votesRef = userCopy["votes"];

Expand Down Expand Up @@ -616,7 +616,7 @@ ModelsCollection<User> users {
{{"id", 5}, {"name", "Rose"}},
};

users.modelKeys(); // Returns QVector<QVariant>
users.modelKeys(); // Returns QList<QVariant>
users.modelKeys<quint64>();

// {1, 2, 3, 5}
Expand All @@ -638,7 +638,7 @@ For the inverse of `only`, see the [except](#method-except) method.
#### `pluck()` {#method-pluck}
The `pluck` method retrieves all of the values for a given column, the following overload returns the `QVector<QVariant>`:
The `pluck` method retrieves all of the values for a given column, the following overload returns the `QList<QVariant>`:
```cpp
ModelsCollection<Product> products {
Expand All @@ -651,7 +651,7 @@ auto plucked = products.pluck("name");
// {Desk, Chair}
```

The second overload allows returning the custom type `QVector<T>`:
The second overload allows returning the custom type `QList<T>`:

```cpp
auto plucked = products.pluck<QString>("name");
Expand Down Expand Up @@ -915,7 +915,7 @@ It can be also called on `ModelsCollection` rvalues, it returns an rvalue refere
The `toBase` method returns a copy of the underlying vector represented by the collection:

```cpp
QVector<User> = users.toBase();
QList<User> = users.toBase();
```

:::note
Expand All @@ -942,13 +942,13 @@ The `toJsonDocument` method converts the collection of models with all nested re

#### `toMap()` {#method-tomap}

The `toMap` method converts the collection of models with all nested relations into an attributes map `QVector<QVariantMap>`.
The `toMap` method converts the collection of models with all nested relations into an attributes map `QList<QVariantMap>`.

It returns an empty `QVariantList` for empty `many` type relations and a null <abbr title='QVariant::fromValue(nullptr)'>`QVariant`</abbr> for empty `one` type relations.

#### `toMapVariantList()` {#method-tomapvariantlist}

The `toMapVariantList` method converts the collection of models with all nested relations into an attributes map, but it returns the <abbr title='QList<QVariant>'>`QVariantList`</abbr> instead of the `QVector<QVariantMap>`.
The `toMapVariantList` method converts the collection of models with all nested relations into an attributes map, but it returns the <abbr title='QList<QVariant>'>`QVariantList`</abbr> instead of the `QList<QVariantMap>`.

It returns an empty `QVariantList` for empty `many` type relations and a null <abbr title='QVariant::fromValue(nullptr)'>`QVariant`</abbr> for empty `one` type relations.

Expand All @@ -972,13 +972,13 @@ users.toQuery()->update({
#### `toList()` {#method-tolist}
The `toList` method converts the collection of models with all nested relations into an attributes vector `QVector<QVector<AttributeItem>>`.
The `toList` method converts the collection of models with all nested relations into an attributes vector `QList<QList<AttributeItem>>`.
It returns an empty `QVariantList` for empty `many` type relations and a null <abbr title='QVariant::fromValue(nullptr)'>`QVariant`</abbr> for empty `one` type relations.
#### `toListVariantList()` {#method-tolistvariantlist}
The `toListVariantList` method converts the collection of models with all nested relations into an attributes vector, but it returns the <abbr title='QList<QVariant>'>`QVariantList`</abbr> instead of the `QVector<QVector<AttributeItem>>`.
The `toListVariantList` method converts the collection of models with all nested relations into an attributes vector, but it returns the <abbr title='QList<QVariant>'>`QVariantList`</abbr> instead of the `QList<QList<AttributeItem>>`.
It returns an empty `QVariantList` for empty `many` type relations and a null <abbr title='QVariant::fromValue(nullptr)'>`QVariant`</abbr> for empty `one` type relations.
Expand Down
14 changes: 7 additions & 7 deletions docs/tinyorm/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ class Flight final : public Model<Flight>

private:
/*! The model's default values for attributes. */
inline static const QVector<AttributeItem> u_attributes {
inline static const QList<AttributeItem> u_attributes {
{"delayed", false},
{"progress", 0},
{"added_on", QDateTime::currentDateTimeUtc()},
Expand Down Expand Up @@ -454,7 +454,7 @@ flight->getAttribute("number"); // "FR 900"
### Containers
As we have seen, TinyORM methods like `all` and `get` retrieve multiple records from the database. Since these methods return a `QVector<Model>`, you can iterate it like any other container with the [Range-based for loop](https://en.cppreference.com/w/cpp/language/range-for), [STL-Style Iterators](https://doc.qt.io/qt/containers.html#stl-style-iterators), [Java-Style Iterators](https://doc.qt.io/qt/containers.html#java-style-iterators) or [Ranges](https://www.walletfox.com/course/quickref_range_v3.php).
As we have seen, TinyORM methods like `all` and `get` retrieve multiple records from the database. Since these methods return a `QList<Model>`, you can iterate it like any other container with the [Range-based for loop](https://en.cppreference.com/w/cpp/language/range-for), [STL-Style Iterators](https://doc.qt.io/qt/containers.html#stl-style-iterators), [Java-Style Iterators](https://doc.qt.io/qt/containers.html#java-style-iterators) or [Ranges](https://www.walletfox.com/course/quickref_range_v3.php).
```cpp
#include <QDebug>
Expand All @@ -476,7 +476,7 @@ Your application may run out of memory if you attempt to load tens of thousands
The `chunk` method will retrieve a subset of TinyORM models, passing them to a lambda expression for processing. Since only the current chunk of TinyORM models is retrieved at a time, the `chunk` method will provide significantly reduced memory usage when working with a large number of models:
```cpp
Flight::chunk(200, [](QVector<Flight> &&flights, const int /*unused*/)
Flight::chunk(200, [](QList<Flight> &&flights, const int /*unused*/)
{
for (auto &&flight : flights) {
//
Expand All @@ -492,7 +492,7 @@ If you are filtering the results of the `chunk` method based on a column that yo
```cpp
Flight::whereEq("departed", true)
->chunkById(200, [](QVector<Flight> &&flights, const int /*unused*/)
->chunkById(200, [](QList<Flight> &&flights, const int /*unused*/)
{
for (auto &&flight : flights)
flight.update({{"departed", false}});
Expand Down Expand Up @@ -575,7 +575,7 @@ auto flight = Flight::findOr<std::optional<Flight>>(1, [] {
});
```
To obtain only a subset of the model's attributes you may use the `Model::only` method, it returns the `QVector<AttributeItem>`:
To obtain only a subset of the model's attributes you may use the `Model::only` method, it returns the `QList<AttributeItem>`:
```cpp
#include "models/flight.hpp"
Expand All @@ -600,7 +600,7 @@ auto flight = Flight::where("legs", ">", 3)->firstOrFail();
### Retrieving Or Creating Models
The `firstOrCreate` method will attempt to locate a database record using the given column / value pairs. If the model can not be found in the database, a record will be inserted with the attributes resulting from merging the first `QVector<Orm::WhereItem>` argument with the optional second `QVector<Orm::AttributeItem>` argument:
The `firstOrCreate` method will attempt to locate a database record using the given column / value pairs. If the model can not be found in the database, a record will be inserted with the attributes resulting from merging the first `QList<Orm::WhereItem>` argument with the optional second `QList<Orm::AttributeItem>` argument:
The `firstOrNew` method, like `firstOrCreate`, will attempt to locate a record in the database matching the given attributes. However, if a model is not found, a new model instance will be returned. Note that the model returned by `firstOrNew` has not yet been persisted to the database. You will need to manually call the `save` method to persist it:
Expand Down Expand Up @@ -693,7 +693,7 @@ Flight::whereEq("active", 1)
.update({{"delayed", 1}});
```
The `update` method expects the `QVector<Orm::UpdateItem>` of column and value pairs representing the columns that should be updated.
The `update` method expects the `QList<Orm::UpdateItem>` of column and value pairs representing the columns that should be updated.
#### Examining Attribute Changes
Expand Down
Loading

0 comments on commit 4c031cd

Please sign in to comment.