Thursday, 11 May 2017

Mongoose access from angular controller

I try to do a simple server/client in node/angular connected with mangoose to a mangoDB

my structure :

app/
   app.js   (mongoose connect / schema /models )
   bower.json
   components/
      app.module.js
      app.routes.js
      artistes/
        addArtist.html
        addArtistController.js
      home/ (html controller service)
   shared/ (header & footer html)
   assets/  (css/js/img/fonts)
   bower_components/  
   index.html (main index)
data/    (mongo db)
mongod*        (script to launch mongodo)
package.json   (npm start)
routes/
bin/  
models/  (empty)
node_modules/     
server.js

I want to group all the mongoose logic in the server.js then when it will work i'll put the model in a model directory, but not now.

My server got the mangoose connect, schema and model creation a save function and a find function. But i m totally lost for this :

  • how in my addArtistController can I access my save and find function from server.js ? i can t require('mongoose') as require is not made for browser side. thanks for your help, any example would work thanks


via Chim

No comments:

Post a Comment