Commit 0f154540 by qiuzhi99

add mongodb database

1 parent 769951e1
...@@ -2,6 +2,8 @@ const { ApolloServer } = require("apollo-server"); ...@@ -2,6 +2,8 @@ const { ApolloServer } = require("apollo-server");
const gql = require("graphql-tag"); const gql = require("graphql-tag");
const mongoose = require("mongoose");
const typeDefs = gql` const typeDefs = gql`
type Query { type Query {
sayHi: String! sayHi: String!
...@@ -19,6 +21,14 @@ const server = new ApolloServer({ ...@@ -19,6 +21,14 @@ const server = new ApolloServer({
resolvers resolvers
}); });
server.listen({ port: 5001 }).then(res => { mongoose
console.log(`Server running at ${res.url}`); .connect("mongodb://test:A12345678@ds119820.mlab.com:19820/merng", {
}); useNewUrlParser: true
})
.then(() => {
console.log("MongoDB Connected");
return server.listen({ port: 5001 });
})
.then(res => {
console.log(`Server running at ${res.url}`);
});
File mode changed
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!