arashsheyda / nuxt-mongoose

A Nuxt module for simplifying the use of Mongoose in your project.
https://docs.arashsheyda.me/nuxt-mongoose
76 stars 14 forks source link

Displaying data #15

Closed R0N1n-dev closed 1 year ago

R0N1n-dev commented 1 year ago

Screenshot from 2023-08-09 15-03-55 Screenshot from 2023-08-09 14-59-40 Screenshot from 2023-08-09 14-59-32 Screenshot from 2023-08-09 14-59-20 Screenshot from 2023-08-09 15-00-28

Have installed the package and followed instructions but cant display data. The dev tools query show no response. Whats going on coz i Have no errors but clearly am not getting any data from my database. What is the right way to do this coz the documentation is scant

arashsheyda commented 1 year ago

hey. There is nothing wrong with your setup, as you can see in the server-routes from devtools, it's returning an empty array, just make sure you have a record in your collection.

if you are sure that you have some records and still nothing is showing up, can you share a minimal reproduction of your project? thanks

arashsheyda commented 1 year ago

@R0N1n-dev and also you can auto-import your models. the default folder for auto-import is ~/server/models and you can change it from your nuxt-config, an example would be like:

export default defineNuxtConfig({
  devtools: { enabled: true },

  modules: [
    'nuxt-mongoose',
  ],

  mongoose: {
    uri: 'mongodb://127.0.0.1:27017/nuxt-mongoose',
    modelsDir: '../models', //here we are setting the modelsDir to `~/models`
  },
})
R0N1n-dev commented 1 year ago

Ok, thats fixed but now i have no idea on how to add data coz my code is not working. https://stackblitz.com/github/R0N1n-dev/nuxt-mongoose. i get an error on post request

arashsheyda commented 1 year ago

@R0N1n-dev it's not related to this module, if you want to use insertOne in mongoose, you either need to write it like GameSchema.collection.insertOne or you can simply use GameSchema.create

aslo I encourage you to use typescript :) mongoose supports typescript and it will help you to solve things faster

R0N1n-dev commented 1 year ago

Thank you

arashsheyda commented 1 year ago

No problem, feel free to ask any other question if you have, just DM me on twitter

R0N1n-dev commented 1 year ago

Will do. I love mongodb and so this plugin will really help. Good day