basic csv support
+ csv imports + import options + type detection + bool, number, date, text, email and json types supported
This commit is contained in:
67
README.md
Normal file
67
README.md
Normal file
@ -0,0 +1,67 @@
|
||||
# Overview
|
||||
|
||||
PocketBase data import tools for CSV and JSON files made using
|
||||
[PocketBase JS SDK](https://github.com/pocketbase/js-sdk).
|
||||
|
||||
Automatically creates typed PocketBase collection and populates it with data.
|
||||
|
||||
Columns conflicting with PocketBase's autogenerated system fields (`id`,
|
||||
`created`, `updated`; case-insensitive check, target column name's case is not
|
||||
affected) are prefixed with `_`.
|
||||
|
||||
## Types
|
||||
|
||||
`pocketbase-import` detects types using regular expressions. Currently supported
|
||||
PocketBase types are:
|
||||
|
||||
- `Bool`
|
||||
- `Number`
|
||||
- `Plain text`
|
||||
- `Email`
|
||||
- `DateTime`
|
||||
- `JSON`
|
||||
|
||||
# Configuration
|
||||
|
||||
In the root directory create `.env` file with the following environment
|
||||
variables:
|
||||
|
||||
- `ADMIN_EMAIL` (required) - superadmin email
|
||||
- `ADMIN_PASSWORD` (required) - superadmin password
|
||||
- `POCKETBASE_URL` (optional) - PocketBase app URL, defaults to local instance
|
||||
|
||||
Place your import files inside of `input` directory.
|
||||
|
||||
# Options
|
||||
|
||||
You can change the default import options to your needs:
|
||||
|
||||
| Name | Files | Required | Description | Example use |
|
||||
| --------- | -------- | -------- | ------------------------------------------------------------------------------------------ | ------------------- |
|
||||
| input | CSV/JSON | Yes | The name of the input file (with extension) | --input=example.csv |
|
||||
| id | CSV/JSON | No | Indicates that `_id` column should be typed as plain text, the type is detected by default | --id |
|
||||
| lf | CSV | No | LF (`\n`) EOL character will be used instead of default CLRF (`\r\n`) | --lf |
|
||||
| delimiter | CSV | No | Column value separator, defaults to `,` | --delimiter=; |
|
||||
| quote | CSV | No | Value quote character, defaults to `'` | --quote=~ |
|
||||
|
||||
# CSV
|
||||
|
||||
## Examples
|
||||
|
||||
Basic import (root directory):
|
||||
|
||||
```
|
||||
deno run csv.ts --input=example.csv
|
||||
```
|
||||
|
||||
Import without permission prompts and with `_id` column as text:
|
||||
|
||||
```
|
||||
deno run --allow-read --allow-env --allow-net csv.ts --input=example.csv --id
|
||||
```
|
||||
|
||||
Import with custom parser options (you need to adjust `example.csv`):
|
||||
|
||||
```
|
||||
deno run csv.ts --input=example.csv --delimiter=; --query=~ --lf
|
||||
```
|
Reference in New Issue
Block a user