Skip to content

Commit c2c47c7

Browse files
committed
docs: updated with new features and fixes
1 parent be8411f commit c2c47c7

86 files changed

Lines changed: 401 additions & 119 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/auditing/_category_.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"label": "Auditing",
3-
"position": 11,
3+
"position": 12,
44
"link": {
55
"type": "generated-index"
66
}

docs/auditing/enable-auditing.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ It internally makes use of the `Triggers` defined within Elemental. This means t
1616
CastleModel.EnableAuditing()
1717
```
1818

19+
#### Alternatively you can pass `Audting` as `true` within the schema options when creating a new model.
20+
1921
## TODO
2022

2123
- [ ] Implement concurrency control to make sure that the same audit log is not written multiple times.

docs/benchmarks/_category_.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"label": "Benchmarks",
3-
"position": 13,
3+
"position": 15,
44
"link": {
55
"type": "generated-index"
66
}

docs/cli/_category_.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"label": "CLI",
3+
"position": 11,
4+
"link": {
5+
"type": "generated-index"
6+
}
7+
}

docs/cli/commands/_category_.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"label": "Commands",
3+
"position": 2,
4+
"link": {
5+
"type": "generated-index"
6+
}
7+
}

docs/cli/commands/init.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
sidebar_position: 1
3+
---
4+
5+
# Init
6+
7+
Initializes a new default configuration file for the Elemental CLI.
8+
9+
```bash
10+
elemental init
11+
```
12+
13+
You can also specify a MongoDB connection string as an argument to the command. This will be used as the connection string in the configuration file.
14+
15+
```bash
16+
elemental init mongodb://localhost:27017
17+
```
18+
19+
## The configuration file
20+
21+
The elemental config file is a YAML or JSON file with one of the following names:
22+
23+
- .elementalrc
24+
- .elemental.yaml
25+
- .elemental.yml
26+
- elemental.json
27+
- elemental.yaml
28+
- elemental.yml
29+
30+
The default configuration file is `.elementalrc`. The configuration file is created in the current working directory when you run the `elemental init` command. If a configuration file already exists, it will not be overwritten.
31+
32+
## Example configuration file
33+
34+
```json
35+
{
36+
"connection_str": "mongodb://localhost:27017",
37+
"migrations_dir": "database/migrations",
38+
"seeds_dir": "database/seeds",
39+
"changelog_collection": "changelog"
40+
}
41+
```
42+
43+
### Environment variables
44+
45+
The elemental config file also supports reading from environment variables. For example, you can specify the `connection_str` as `<DB_CONNECTION_STRING>` in the config file, and it will be replaced with the value of the `DB_CONNECTION_STRING` environment variable during runtime.
46+
47+
```json
48+
{
49+
"connection_str": "<DB_CONNECTION_STRING>"
50+
}
51+
```
52+
53+
If a `.env` file is present in the same directory as the config file, it will pick up the environment variables from there. It also uses the environemnt variable `APP_ENV` to look for .env file variants if specified. If the `APP_ENV` variable is set to `production`, it will look for a `.env.production` file. If it is set to `development`, it will look for a `.env.development` file. The environment variables are loaded using the [**godotenv**](https://github.com/joho/godotenv) package.

docs/cli/commands/migrate.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
sidebar_position: 2
3+
---
4+
5+
# Migrate
6+
7+
Create, apply and rollback migrations using the Elemental CLI.
8+
9+
## Create a migration
10+
11+
The migration file will be created in the `migrations_dir` specified in the configuration file. By default, this is `database/migrations`.
12+
13+
```bash
14+
elemental migrate create <migration_name>
15+
```
16+
17+
## Run migrations
18+
19+
Run all pending migrations. This will create a changelog collection in the database if it does not exist. By default, this is `changelog`.
20+
21+
```bash
22+
elemental migrate up
23+
```
24+
25+
## Rollback migrations
26+
27+
Rollback the last migration. This will remove the last entry in the changelog collection.
28+
29+
```bash
30+
elemental migrate down
31+
```

docs/cli/commands/seed.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
sidebar_position: 3
3+
---
4+
5+
# Seed
6+
7+
Create, apply and rollback seeds using the Elemental CLI.
8+
9+
## Create a seeder
10+
11+
The seeder will be created in the `seeds_dir` specified in the configuration file. By default, this is `database/seeds`.
12+
13+
```bash
14+
elemental seed create <seeder_name>
15+
```
16+
17+
## Run seeders
18+
19+
Run all pending seeds. This will create a changelog collection in the database if it does not exist. By default, this is `changelog`.
20+
21+
```bash
22+
elemental seed up
23+
```
24+
25+
## Rollback seeders
26+
27+
Rollback the last seed. This will remove the last entry in the changelog collection.
28+
29+
```bash
30+
elemental seed down
31+
```

docs/cli/index.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
sidebar_position: 1
3+
---
4+
5+
# Installation
6+
7+
The Elemental CLI is a command-line tool that helps you manage stuff such as migrations and seeders. It is still in its early stages, but it is already quite useful. You can install it with the following command:
8+
9+
```bash
10+
go install github.com/elcengine/elemental@latest
11+
```

docs/cross-connection-queries/switching-collections.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ sidebar_position: 4
77
The Elemental ORM allows you to switch between different collections in the middle of a query. This is useful when you have multiple collections and you need to query data from both.
88

99
```go
10-
witchers := WitcherModel.Find().SetCollection("secondary-collection").Exec().([]Witcher)
10+
witchers := WitcherModel.Find().SetCollection("secondary-collection").ExecTT()
1111
```
1212

1313
In the example above, we are switching the collection to `secondary-collection` before executing the query. This will ensure that the query is executed on the `secondary-collection` collection.

0 commit comments

Comments
 (0)