Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9291785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T20:43:55+00:00 2026-06-18T20:43:55+00:00

This is my model: var UserSchema = new Schema({ username: { type: String, unique:

  • 0

This is my model:

var UserSchema = new Schema({
    username: { type: String, unique: true, index: true },
    url: { type: String },
    name: { type: String },
    github_id: { type: Number },
    avatar_url: { type: String },
    location: { type: String },
    email: { type: String },
    blog: { type: String },
    public_repos: { type: Number },
    public_gists: { type: Number },
    last_github_sync: { type: Date },
    created_at: { type: Date, default: Date.now }
});

I try to update my document with findOneAndUpdate function:

Doesn’t work:

User.findOneAndUpdate({ github_id: 1 }, { last_github_sync: new Date() }, {});

Doesn’t work:

User.findOneAndUpdate({ github_id: 1 }, { last_github_sync: new Date() });

Works:

User.findOneAndUpdate({ github_id: 1 }, { last_github_sync: new Date() }, {}, function (err, numberAffected, raw) { });

I mean I should bind callback function to make the update operation work but I don’t need that callback function, what’s the problem with my code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T20:43:56+00:00Added an answer on June 18, 2026 at 8:43 pm

    See the examples in the findOneAndUpdate documentation:

    A.findOneAndUpdate(conditions, update, options, callback) // executes
    A.findOneAndUpdate(conditions, update, options)  // returns Query
    A.findOneAndUpdate(conditions, update, callback) // executes
    A.findOneAndUpdate(conditions, update)           // returns Query
    A.findOneAndUpdate()                             // returns Query
    

    If you don’t provide a callback, it returns a Query object that you must call exec() on to execute the update.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code var UserSchema = new Schema({ Username: {type: String, index: true},
I have this model: var HuntGroupSchema = new Schema({ name : { type: String,
In mongoose I've got this model: var userschema = new mongoose.Schema({ user: String, following:
This is my Schema: var userschema = new mongoose.Schema({ user: String, follow: [String], imagen:
I have a userSchema that looks like this: var userSchema = new Schema({ name:
I'm giving up. I have a Schema defined like this: var UserSchema = new
I have this model var Item = Backbone.Model.extend({ url: 'http://localhost/InterprisePOS/Product/loaditembycategory/Event Materials' }); var onSuccess
This is my model. UserApiSchema.statics.createApi = function(user,fn){ var instance = new UserApi(); instance.user =
I've got something like this: var mongoose = require('mongoose'); mongoose.connect('mongodb://...'); var UserSchema = mongoose.Schema({
I have something like this: var model = forumsDb.Categories .Select(c => new {c, c.Threads.Count})

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.