Skip to content

Commit

Permalink
[automated commit] Bump docs to versions 2.5.0, 1.53.3
Browse files Browse the repository at this point in the history
  • Loading branch information
leorossi authored and github-actions[bot] committed Oct 7, 2024
1 parent 8af1c48 commit a7c768b
Show file tree
Hide file tree
Showing 184 changed files with 13 additions and 9 deletions.
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ To ensure that a specific user has the correct access rights to use entities wit
//plugin.js

app.post('/', async (req, reply) => {
const ctx = req.createPlatformaticCtx()
const ctx = req.platformaticContext

await app.platformatic.entities.movie.find({
where: { /*...*/ },
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Here's how you can integrate context into your plugin:

```js
app.post('/', async (req, reply) => {
const ctx = req.createPlatformaticCtx()
const ctx = req.platformaticContext

await app.platformatic.entities.movies.find({
where: { /*...*/ },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ Platformatic DB uses [SQLite](https://www.sqlite.org/) as the default database f

For the Todo API, we need two tables, Users and Todos, let's edit the migrations generated by [Platformatic CLI](../../cli.md) to add these tables:

### Creating a User table
### Creating a Users table

To create the users table, navigate to the `db/migrations` directory and edit `001.do.sql` file, and add the schema below:

```sql
CREATE TABLE IF NOT EXISTS User (
CREATE TABLE IF NOT EXISTS Users (
id INTEGER PRIMARY KEY,
username TEXT NOT NULL UNIQUE,
password TEXT NOT NULL,
Expand All @@ -60,13 +60,17 @@ CREATE TABLE IF NOT EXISTS User (
And let's edit the `migrations/001.undo.sql` file to look like this:

```sql
DROP TABLE User;
DROP TABLE Users;
```
:::note
To ensure the OpenAPI specification accurately reflects your API endpoints, it's essential to use plural table names.
:::


Before we apply the migrations, let's create a new table for our Todos, to do that create another file `002.do.sql` and inside it, add the schema for your Todos table.

```sql
CREATE TABLE IF NOT EXISTS Todo (
CREATE TABLE IF NOT EXISTS Todos (
id INTEGER PRIMARY KEY,
user_id INTEGER,
title TEXT NOT NULL,
Expand All @@ -79,7 +83,7 @@ CREATE TABLE IF NOT EXISTS Todo (
And again, add a new file `002.undo.sql` to drop the table.

```sql
DROP TABLE Todo;
DROP TABLE Todos;
```

:::note
Expand Down Expand Up @@ -118,4 +122,4 @@ You should get a **200 OK** status code for a successful request.

## Conclusion

Congratulations! You have successfully created a simple Todo API using Platformatic. This tutorial covered the basics of setting up a Platformatic project, defining a schema, configuring the service, and creating API endpoints. For more advanced features and configurations, refer to the [Platformatic API Documentation](../../cli.md).
Congratulations! You have successfully created a simple Todo API using Platformatic. This tutorial covered the basics of setting up a Platformatic project, defining a schema, configuring the service, and creating API endpoints. For more advanced features and configurations, refer to the [Platformatic API Documentation](../../cli.md).
2 changes: 1 addition & 1 deletion versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[
"2.4.0",
"2.5.0",
"1.53.3"
]

0 comments on commit a7c768b

Please sign in to comment.