Skip to content

Setup/Config Question(s) #55

@aaronfischer

Description

@aaronfischer

I'll preface this with I'm new to mongo/express/jsonapi-server/etc.

I've setup the jsonapi-server using the MemoryHandler with examples:[...] successfully. However, I want to actually set things up using an actual DB so I've chosen mongo.
I'm not entirely sure what is required by this package though, but I setup a DB through "mLab" and my jsonApi.define looks something like this now:

...
var MongoStore = require('jsonapi-store-mongodb');

var port = 3000;

var jsonApiRouter = new express.Router();

jsonApi.setConfig({
  router: jsonApiRouter,
  graphiql: false,
});

app.use('/', jsonApiRouter);

jsonApi.define({
  resource: 'drinks',
  // handlers: new jsonApi.MemoryHandler(),
  handlers: new MongoStore({
    url: 'mongodb://<user>:<pass>@123456.mlab.com:59117/wedrinkin_db',
  }),
  ...

Beyond this, I'm not sure what else is required. Obviously when I visit: http://localhost:3000/drinks I don't see any data, even though I have loaded a few documents into a "drinks" collection/db on mLab. I also don't see any errors though.

Any advice/tips are helpful!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions