Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update MongoDB records #30

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DATABASE_URL=postgresql://admin:superadmin@localhost:5432/postgres
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,15 @@ You can do this by running:

```
yarn lint
yarn test
```

Make sure you have an `.env` file with `DATABASE_URL` specified.
### To run test do next:
```
1. cp .env.example .env
2. docker-compose up -d
3. yarn prisma-migrate
4. yarn test
```

## License

Expand Down
17 changes: 17 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: '3'

services:
postgres-local:
container_name: adminjs_prisma
image: postgres
restart: always
environment:
POSTGRES_DB: postgres
POSTGRES_USER: admin
POSTGRES_PASSWORD: superadmin
PGDATA: /data/postgres
ports:
- '5432:5432'

volumes:
data:
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adminjs/prisma",
"version": "3.0.1",
"version": "3.0.2",
"description": "Prisma adapter for AdminJS",
"keywords": [
"prisma",
Expand All @@ -20,7 +20,8 @@
"ts-node": "ts-node",
"lint": "eslint './src/**/*.{ts,js}' './spec/**/*.{ts,js}' './example-app/**/*.{ts,js}' --ignore-pattern 'build' --ignore-pattern 'yarn.lock'",
"check:all": "yarn lint && yarn test && yarn build",
"release": "semantic-release"
"release": "semantic-release",
"prisma-migrate": "prisma migrate dev --name init"
},
"repository": {
"type": "git",
Expand Down
3 changes: 3 additions & 0 deletions src/Resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ export class Resource extends BaseResource {
const param = flat.get(params, property.path());
const key = property.path();

// eslint-disable-next-line no-continue
if (key === 'id') continue;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if primary key's name is not id?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can use method isId() on the property object

if(property.isId()) continue;


// eslint-disable-next-line no-continue
if (param === undefined) continue;

Expand Down