Skip to content

Instantly share code, notes, and snippets.

version: '3'
services:
app:
container_name: docker_nodejsauth
restart: always
build: .
ports:
- 4001:4001
links:
- mongo
version: '3'
services:
app:
container_name: docker_nodejsauth
restart: always
build: .
ports:
- 4001:4001
links:
- mongo
version: '3'
services:
app:
container_name: docker_nodejsauth
restart: always
build: .
ports:
- 4001:4001
links:
- mongo
FROM node:alpine
WORKDIR '/usr/app'
COPY package*.json ./
RUN npm install
COPY ./ ./
EXPOSE 3000
CMD npm start
options:{
sort:{
createdAt : -1 //descending order
}
}
// OR
options:{
sort:{
router.get('/posts',authenticate, async (req,res) => {
//const _ispublished = req.query.published;
const match = {}
const sort = {}
if(req.query.published){
match.published = req.query.published === 'true'
}
if(req.query.sortBy && req.query.OrderBy){
router.get('/posts',authenticate, async (req,res) => {
//const _ispublished = req.query.published;
const match = {}
if(req.query.published){
match.published = req.query.published === 'true'
}
try {
await req.user.populate({
path:'posts',
router.get('/posts',authenticate, async (req,res) => {
//const _ispublished = req.query.published;
const match = {}
if(req.query.published){
match.published = req.query.published === 'true'
}
try {
await req.user.populate({
path:'posts',
router.get('/posts',authenticate, async (req,res) => {
try {
await req.user.populate('posts).execPopulate()
res.send(req.user.posts)
} catch (error) {
res.status(500).send()
}
})
updatePost(parent,args, ctx, info){
const post = ctx.posts.find((post) => post.id === args.id)
const originalPost = {...post} //spread operator
if (!post) {
throw new Error('Post not found')
}
if (typeof args.body === 'string') {
post.body = args.body
}