Comments (5)
@ZanderFoster I've just tested in our test app with Organization
and Person
:
model Organization {
id Int @id @default(autoincrement())
name String
persons Person[]
@@map("organizations")
}
model Person {
id Int @id @default(autoincrement())
firstName String @map("first_name")
lastName String @map("last_name")
email String
organization Organization @relation(fields: [organizationId], references: [id])
organizationId Int @map("organization_id")
teams TeamMember[]
@@map("persons")
}
Resource:
{
resource: { model: getModelByName('Organization'), client: prisma },
features: [
owningRelationSettingsFeature({
componentLoader,
licenseKey: process.env.LICENSE_KEY,
relations: {
persons: {
type: RelationType.OneToMany,
target: {
joinKey: 'organization',
resourceId: 'Person',
},
},
},
}),
],
}
This works for me which is similar to your setup. Do you have any extra resource options in LicenseKey or Application resources?
from adminjs.
Nothing that I can tell would interfere, maybe you can spot something?
Application
import { getModelByName } from '@adminjs/prisma'
import { PrismaClient } from '@prisma/client';
import loggerFeature from '@adminjs/logger';
import componentLoader from '../admin/component-loader.js';
import { isAdmin } from '../admin/roles.js';
const hasAccess = ({ currentAdmin }) => currentAdmin && isAdmin(currentAdmin.email);
const prisma = new PrismaClient();
const panelNavigation =
{
name: 'Panel',
icon: 'Shield',
}
export const createApplicationResource = () => (
{
resource: {
model: getModelByName('Application'),
client: prisma,
},
options: {
navigation: panelNavigation,
sort: {
sortBy: 'name',
direction: 'desc',
},
actions: {
new: {
isAccessible: hasAccess,
},
show: {
isAccessible: hasAccess,
},
edit: {
isAccessible: hasAccess,
},
list: {
isAccessible: hasAccess,
},
},
properties: {
id: {
isVisible: false,
},
createdAt: {
isVisible: false,
},
updatedAt: {
isVisible: false,
},
secret: {
isVisible: {
list: false,
show: true,
edit: false,
filter: false,
},
},
},
},
features: [
loggerFeature({
componentLoader,
propertiesMapping: {
user: 'userId',
},
userIdAttribute: 'email',
}),
owningRelationSettingsFeature({
componentLoader,
licenseKey: process.env.ADMINJS_RELATIONS_LICENSEKEY,
relations: {
keys: {
type: RelationType.OneToMany,
target: {
joinKey: 'appId',
resourceId: 'LicenseKey',
},
},
},
}),
]
});
License:
import { getModelByName } from '@adminjs/prisma'
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
export const createLicenseKeyResource = () => ({
resource: {
model: getModelByName('LicenseKey'),
client: prisma,
},
options: {
properties: {
id: {
isVisible: false,
},
lastUsed: {
isVisible: false,
},
updatedAt: {
isVisible: false,
},
key: {
isVisible: {
list: false,
show: true,
edit: false,
filter: false,
},
},
},
},
features: [targetRelationSettingsFeature()],
});
from adminjs.
@dziraf I've removed the options section from both applications and licenses, still getting the null (reading 'type') error.
from adminjs.
It should work if you change appId
to app
- @adminjs/prisma
uses relation names from schema to query the database.
I think the sorting error you're getting is due to:
sort: {
sortBy: 'name',
direction: 'desc',
},
It should probably work if you remove. I'll take a look at the code why it causes the error though.
from adminjs.
It should work if you change
appId
toapp
-@adminjs/prisma
uses relation names from schema to query the database.I think the sorting error you're getting is due to:
sort: { sortBy: 'name', direction: 'desc', },It should probably work if you remove. I'll take a look at the code why it causes the error though.
That did the trick, Seems to be loading correctly now.
from adminjs.
Related Issues (20)
- Map leaflet property position cannot be changed HOT 1
- Leaflet shows error when creating a new record HOT 3
- @adminjs/relations rendering error: Error: Component "RelationsShowPropertyComponent" has not been bundled HOT 1
- [Bug]: Admim js Dashboard takes very long time to load the page. HOT 1
- [Feature]: Overriding the create new resource actions button HOT 1
- [Feature]: [@adminjs/relations] Add custom properties/columns.
- [Feature]: function for guard instead of only string
- How can I query a record or a list of records with exact matching property values?
- [Bug]: Custom Component is taking too long to load and resulting in heap memory out of usage. HOT 2
- [Bug]: [@admins/relations] custom action icon not shown
- [Bug]: Nav bar logo does not change in dark theme.
- How do I call aws-sdk from client? HOT 1
- Unable to access data sent from frontend to custom endpoint HOT 9
- [Bug]: Relations: Bugs in deleting many-to-many item HOT 8
- [Bug]: Use import specifier 'with' instead of 'assert'
- [Bug]: @adminjs/relations default sorting not working in oneToManyHandler
- [Bug]: Leaflet Maps not rendering properly in production
- [Bug]: recharts module not found HOT 2
- [Feature]: Guard is not supported for basic types
- [Bug]: href with search filter on resource removes sidebar navigation active state for the page using it
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from adminjs.