Giter Site home page Giter Site logo

Type error about rest-api-playlist HOT 2 CLOSED

iamshaunjp avatar iamshaunjp commented on July 17, 2024
Type error

from rest-api-playlist.

Comments (2)

tchasinga avatar tchasinga commented on July 17, 2024 2

instead of type
"module.export = NameOfModel"
type this :
module.exports = name of model

and it will work because that code gotta be 'exports' but not 'export'
I'd the same issue

from rest-api-playlist.

deepakmalikk avatar deepakmalikk commented on July 17, 2024

const express =require('express')
const mongo = require('mongoose')
const router =express.Router()
const Ninja=require('../models/ninja')
mongo.set('useCreateIndex',true)
//get a list of ninjas from db
router.get('/ninjas',function(req,res,next){

Ninja.aggregate([{
    $geoNear:{

near:
{type:'point',coordinates:[parseFloat(req.query.lng),parseFloat(req.query.lat)]},
spherical: true ,maxdistance :100000,distanceField: "dist.calulated"}
}]).then(function(ninjas){
res.send(ninjas)
})
})

//add a new of ninjas from db
router.post('/ninjas',function(req,res,next){

Ninja.create(req.body).then((ninja) => {
res.send(ninja)
}).catch(next)

})

// update a new of ninjas from db
router.put('/ninjas/:id',function(req,res,next){
Ninja.findByIdAndUpdate({_id: req.params.id},req.body).then(function()
{ Ninja.findOne({_id: req.params.id},req.body).then(function(ninja){

    res.send(ninja)
})
    
})

})

//Delete a ninjas from db
router.delete('/ninjas/:id',function(req,res,next){

Ninja.findByIdAndRemove({_id: req.params.id}).then(function(ninja){
    res.send(ninja)
})

})

module.exports=router

from rest-api-playlist.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.