@Boadicea45 I believe the issue with the members-dbs
path (aka … the route named membersDbs
):
import { Router, Route } from '@redwoodjs/router'
const Routes = () => {
return (
<Router>
<Route path="/orgs/new" page={NewOrgPage} name="newOrg" />
<Route path="/orgs/{id:Int}/edit" page={EditOrgPage} name="editOrg" />
<Route path="/orgs/{id:Int}" page={OrgPage} name="org" />
<Route path="/orgs" page={OrgsPage} name="orgs" />
<Route path="/members-dbs/new" page={NewMembersDBPage} name="newMembersDB" />
<Route path="/members-dbs/{id:Int}/edit" page={EditMembersDBPage} name="editMembersDB" />
<Route path="/members-dbs/{id:Int}" page={MembersDBPage} name="membersDb" />
<Route path="/members-dbs" page={MembersDBSPage} name="membersDbs" />
<Route path="/members" page={MembersPage} name="members" />
<Route path="/about" page={AboutPage} name="about" />
<Route notfound page={NotFoundPage} />
<Route path="/" page={HomePage} name="home" />
</Router>
)
}
export default Routes
Is with your service and graphql query:
Uncaught Error: Error: Cannot read property 'findMany' of undefined
at withCell.js:106
at Query (Query.js:7)
at renderWithHooks (react-dom.development.js:14803)
at updateFunctionComponent (react-dom.development.js:17034)
which you can see if you view the development tools and console.
The MembersDbPage
uses the MembersDbCell
which queries:
export const QUERY = gql`
query FIND_MEMBERS_DB_BY_ID($id: Int!) {
membersDb: membersDb(id: $id) {
id
email
phone
name
street_address
suburb
state
postcode
}
}
`
But when you look at the service membersDbs.js
:
import { db } from 'src/lib/db'
export const membersDbs = () => {
return db.membersDb.findMany()
}
export const membersDb = ({ id }) => {
return db.membersDb.findOne({
where: { id },
})
}
...
That does match your schema …
export const schema = gql`
type MembersDb {
id: Int!
email: String!
phone: Int
name: String!
street_address: String!
suburb: String!
state: String!
postcode: Int!
}
type Query {
membersDbs: [MembersDb!]!
membersDb(id: Int!): MembersDb
}
...
but that does not match your model:
model Mem {
id Int @id @default(autoincrement())
email String @unique
phone Int?
name String
street_address String
suburb String
state String
postcode Int
}
.
So things are rather out of sync.
I am going to assume you want a table/model named Mem
.
The quickest way to rectify this is to:
yarn rw g scaffold mem --force
And then remove all the other scaffolded/generated sdl, services, pages, etc.
If your issue is that you want Mem
to be named “something else” then you need to cleanup the datatase, rename the model in schema, re-gen/scaffold, etc.
Few notes on your model:
model Mem {
id Int @id @default(autoincrement())
email String @unique
phone Int?
name String
street_address String
suburb String
state String
postcode Int
}
Phone and postcode as Int
may not be the best choice. For example, you could not store +1-555-1212
or a post code of 02113
or any other non US values.
Also, since the structure is the same you could have a Mem
and and Org
with a relation to an Address
– or you could add an enum with a EntityType of MEMBER
or ORG
and use a self-relation: Relations (Reference)
Hope this helps!