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

225
Views
Error: SessionCard validation failed: Cast to string failed for value

I have my schema like this:

const mongoose = require('mongoose');
const Schema = mongoose.Schema;

const sessionCardSchema = new Schema({
  teached: { type: Boolean, default: false },

  interact: {
    pauseTimes: [{ key: Number, type: String, slow: Boolean, time: Number }],
    recordTimes: [{ start: Number, end: Number }],
    recordingStorage: { x: [Number], y: [Number] },
    initialPositions: { left: String, top: String },
  },
});

module.exports = mongoose.model('SessionCard', sessionCardSchema);

And I want to update the interact like this:

console.log(Card);
try {
  const sessionCard = await db.SessionCard.findById(cardID);
  console.log(1);
  sessionCard.teached = true;
  console.log(2);
  sessionCard.interact = Card.interact;
  console.log(3);
  sessionCard.whiteboardSpans = Card.whiteboardSpans;
  console.log(4);
  await sessionCard.save();
  console.log(5);
} catch (err) {
  console.log(err);
}

When there is not document inside interact.pauseTimes there is no error and everything is fine but the issue is if there are documents inside it I get this wired error:

enter image description here

I have no Idea why this is happening and how to fix this, and I think this is another bug for mongodb,

Please help..

EDIT: this is the Card log which I want to save console.log(Card);

enter image description here

about 4 years ago · Juan Pablo Isaza
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!