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

no ability to get all documents using schema.db.todos #684

Open
haluvibe opened this issue Oct 22, 2020 · 3 comments
Open

no ability to get all documents using schema.db.todos #684

haluvibe opened this issue Oct 22, 2020 · 3 comments

Comments

@haluvibe
Copy link

haluvibe commented Oct 22, 2020

export const todosMirageRoutes = (server: Server): void => {
  server.get('/todos', (schema) => {
    return schema.todos.all()
  })

  server.get('/todos/:id', (schema, request) => {
    return schema.db.todos.find(request.params.id)
  })

  server.delete('/todos/:id', (schema, request) => {
    return schema.db.todos.find(request.params.id).destroy()
  })
}

schema.db.todos.find works well, but there is no method on schema.db.todos to return all todos...

@haluvibe
Copy link
Author

and schema.todos.all() works in js but breaks in typescript.

what is the schema.db.todos equivalent?

@delucca
Copy link

delucca commented Nov 5, 2020

Same issue here.

@Je12emy
Copy link

Je12emy commented May 6, 2021

This worked for me, also do check #677 and #682

const addCollectibleRouteHandlers = (server: typeof mockServer) => {
  server.get("/collectible", (schema) => {
    return schema.all("collectible").models;
  });
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants