Skip to content
Merged
14 changes: 11 additions & 3 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,26 @@

- [How it works](getting-started/how-it-works.md)
- [Quick start](getting-started/quick-start.md)
- [Install](getting-started/install.md)
- [Install](getting-started/install/README.md)

- [On Express](getting-started/install/using-express.md)
- [On Koa](getting-started/install/using-koa.md)
- [On Fastify](getting-started/install/using-fastify.md)
- [On NestJS](getting-started/install/using-nest.md)
- [Troubleshooting](getting-started/install/troubleshooting.md)

- [Autocompletion & Typings](getting-started/autocompletion-and-typings.md)

## Data Sources

- [Usage](datasources/README.md)
- [Provided datasources](datasources/provided/README.md)

- [SQL (without ORM)](datasources/provided/sql.md)
- [Sequelize](datasources/provided/sequelize.md)
- [Mongoose](datasources/provided/mongoose.md)

- [Multiple datasources](datasources/multiple-datasources/README.md)
- [Naming conflicts](datasources/multiple-datasources/naming-conflicts.md)
- [Relationships](datasources/multiple-datasources/relationships.md)
- [Write your own](datasources/custom/README.md)
- [Structure declaration](datasources/custom/structure.md)
- [Using a local cache](datasources/custom/local-cache/README.md)
Expand Down
3 changes: 1 addition & 2 deletions docs/agent-customization/relationships/multiple-records.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ agent.customizeCollection('countries', collection =>
collection.addOneToManyRelation('myTowns', 'towns', {
originKey: 'country_id',
originKeyTarget: 'id', // Optional (uses primary key of countries by default)
}
}),
})
);
```

Expand Down
Binary file added docs/assets/quickstart-editor-mode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/quickstart-no-collections.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 1 addition & 56 deletions docs/datasources/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Forest Admin collections map to any of those concepts:

## Example
Comment thread
arnaud-moncel marked this conversation as resolved.

In this example, we import a all tables from a PostgreSQL database into Forest Admin.
In this example, we import all tables from a PostgreSQL database into Forest Admin.

Take note that data sources are defined in independent NPM packages (here `@forestadmin/datasource-sql`).

Expand All @@ -31,58 +31,3 @@ const agent = createAgent(options).addDataSource(
createSqlDataSource('postgres://user:pass@localhost:5432/mySchema'),
);
```

## Naming conflicts

When importing collections to an admin panel, you may encounter naming collisions.

You can tackle them by renaming the collection which are causing issues.

Don't worry if you leave naming collisions, your development agent will warn you while starting.

```javascript
const { createAgent } = require('@forestadmin/agent');
const { createSqlDataSource } = require('@forestadmin/datasource-sql');

const agent = createAgent(options);
const sqlDataSource = new createSqlDataSource('postgres://user:pass@localhost:5432/mySchema');

// Rename sqlDataSource collections by providing replacements
agent.addDataSource(sqlDataSource, {
rename: {
customers: 'superCustomers',
},
});
```

<!--
## Partial imports

Some data source may implement more collections, and associated actions and segments that you want.

By provided options when plugging a data source, you can specify which entities should get loaded.

```javascript
const { createAgent } = require('@forestadmin/agent');
const StripeDataSource = require('@forestadmin/datasource-stripe');

const agent = createAgent(options);
const stripe = new StripeDataSource({ apiKey: 'sk_test_VePHdqKTYQjKNInc7u56JBrQ' });

agent.addDataSource(stripe, {
restrict: {
// Skip 'visitors' collections
collections: ['!visitors'],

// Do not import any action
actions: [],

// Import all fields (this is the default)
fields: ['users.*', 'books.id', 'books.title'],

// Import only segments of the 'charges' collection
segments: ['charges.*'],
},
});
```
-->
17 changes: 17 additions & 0 deletions docs/datasources/multiple-datasources/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
You can plug as many data sources as you want, no matter its type.
For example, you can plug a [Mongoose data source](../provided/mongoose.md) with a [SQL data source](../provided/sql.md). We take care of the compatibility for you.

```javascript
const { createAgent } = require('@forestadmin/agent');
const { createSqlDataSource } = require('@forestadmin/datasource-sql');
const { createMongooseDataSource } = require('@forestadmin/datasource-mongoose');
// Mongoose connection with its model declarations.
const connection = require('./mongoose-models');

// Instantiate data sources.
const sqlDataSource = createSqlDataSource('postgres://user:pass@localhost:5432/mySchema');
const mongooseDataSource = createMongooseDataSource(connection);

// Plug every created data sources to the agent.
const agent = createAgent(options).addDataSource(sqlDataSource).addDataSource(mongooseDataSource);
```
23 changes: 23 additions & 0 deletions docs/datasources/multiple-datasources/naming-conflicts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
When importing collections to an admin panel, you may encounter naming collisions.

You can tackle them by renaming the collection that are causing issues.

Don't worry if you leave naming collisions, your development agent will warn you while starting.

```javascript
const { createAgent } = require('@forestadmin/agent');
const { createSqlDataSource } = require('@forestadmin/datasource-sql');

const agent = createAgent(options);
const sqlDataSource = new createSqlDataSource('postgres://user:pass@localhost:5432/mySchema');

// Rename sqlDataSource collections by providing replacements
agent.addDataSource(sqlDataSource, {
// In this example, it will rename the `customers` and `stores` collections
// to `superCustomers` and `superStores`.
rename: {
customers: 'superCustomers',
stores: 'superStores',
},
});
```
29 changes: 29 additions & 0 deletions docs/datasources/multiple-datasources/relationships.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
The relation mechanism allows you to add a relation between different data sources, regardless of their type.
It is a very powerful feature to link your different data sources.

```javascript
const { createAgent } = require('@forestadmin/agent');
const { createSqlDataSource } = require('@forestadmin/datasource-sql');
const { createMongooseDataSource } = require('@forestadmin/datasource-mongoose');

// Mongoose connection with its model declarations.
const connection = require('./mongoose-models');

// Instanciate data sources.
const sqlDataSource = createSqlDataSource('postgres://user:pass@localhost:5432/mySchema');
const mongooseDataSource = createMongooseDataSource(connection);

// Plug every created data sources to the agent.
const agent = createAgent(options).addDataSource(sqlDataSource).addDataSource(mongooseDataSource);

// Add a relation between a Mongoose collection and a SQL collection.
agent.customizeCollection('countryFromMongoose', collection =>
collection.addOneToManyRelation('towns', 'townsFromSQL', {
originKey: 'country_id',
}),
);
```

{% hint style="info" %}
If you want to know more about adding relation, please refer to this [section](../custom/query-translation/relationships.md).
{% endhint %}
2 changes: 2 additions & 0 deletions docs/datasources/provided/mongoose.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
The mongoose data source allows to import collections from a mongoose instance.

In order to make everything work as expected, you need to install the package `@forestadmin/datasource-mongoose@beta`.

{% tabs %} {% tab title="agent.js" %}

```javascript
Expand Down
2 changes: 2 additions & 0 deletions docs/datasources/provided/sequelize.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
The sequelize data source allows to import collections from a sequelize instance.

In order to make everything work as expected, you need to install the package `@forestadmin/datasource-sequelize@beta`.

Note that:

- Sequelize scopes will be mapped to Forest Admin segments
Expand Down
4 changes: 4 additions & 0 deletions docs/datasources/provided/sql.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
The SQL data source allows to import tables from SQL databases.

In order to make everything work as expected, you need to install the package `@forestadmin/datasource-sql@beta`.

Depending on the database type you want to use, you may also need to install the associated javascript driver (`pg` for postgres, `mysql2` for mariadb/mysql, `tedious` for mssql, etc).

It supports the following vendors:

- Postgres
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started/autocompletion-and-typings.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ In a typescript context, usage of the typing file is pretty straightforward. You

```typescript
import { createAgent } from '@forestadmin/agent';
import Schema from './typings';
import { Schema } from './typings';
import transactions from './customization/transactions';

createAgent<Schema>({
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started/how-it-works.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Before you start writing a single line of code, it’s a good idea to get an ove
Forest Admin provides you with:

- An API hosted on your server to retrieve your data. We call it the **Agent**. It can be a **standalone project** or embedded **within your app**.
- A user interface to access and manage your data from your browser. This **Forest Admin User Interface** is built and managed through ressources hosted on Forest Admin's servers.
- A user interface to access and manage your data from your browser. This **Forest Admin User Interface** is built and managed through resources hosted on Forest Admin's servers.

![The agent is a Node.JS REST API hosted on your servers](../assets/how-it-work-architecture.png)

Expand Down
Loading