Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

206
Views
En mongoose he ejecutado el programa de ejemplo dado en el sitio web pero recibo el mismo error que es: TypeError: fluffy.speak is not a function

const mangosta = require('mangosta');

 main().catch(err => console.log(err)); async function main() { await mongoose.connect('mongodb://localhost:27017/test', { useNewUrlParser: true }); console.log("We are successfully connected"); } const kittySchema = new mongoose.Schema({ name: String }); const Kitten = mongoose.model('Kitten', kittySchema); const silence = new Kitten({ name: 'Silence' }); console.log(silence.name); kittySchema.methods.speak = function speak() { const greeting = this.name ? "Meow name is " + this.name : "I don't have a name"; console.log(greeting); };

This is not running and showing as not a function const fluffy = new Kitten({ name: 'fluffy' }); esponjoso.hablar();

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

En la página Getting Started para mongoose, indica que los métodos deben declararse antes de llamar a mongoose.model() :

 // NOTE: methods must be added to the schema before compiling it with mongoose.model() kittySchema.methods.speak = function speak() { const greeting = this.name ? "Meow name is " + this.name : "I don't have a name"; console.log(greeting); }; const Kitten = mongoose.model('Kitten', kittySchema); ```
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!