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 8433293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:20:52+00:00 2026-06-10T06:20:52+00:00

I have this model: var HuntGroupSchema = new Schema({ name : { type: String,

  • 0

I have this model:

var HuntGroupSchema = new Schema({
    name        : { type: String, required: true }
    ,domain     : { type: ObjectId, required: true, ref: 'Domain' }
    ,members    : [{ type: ObjectId, ref: 'User'}]
    ,email      : { type: String, unique: true}
    ,pin        : { type: Number, default: 0}
    ,extension  : { type: Number, required: true}
    ,timescheme : { type: ObjectId, ref: 'TimeScheme'}
    ,ddi        : { type: String}
});

and have this data

db.huntgroups.find()
{ "_id" : ObjectId("50373487947749f0370000b0"), "ddi" : "01376xxxxxx", "domain" :      ObjectId("502807e9b9e737036d000018"), "email" : "julian@dotr.com", "extension" : 3001,     "members" : [ ObjectId("50376767b5c99cd862000003") ], "name" : "test22", "pin" : 1234 }

and this test always returns -1

// req.params['member'] === '50376767b5c99cd862000003'
var member_id = mongoose.Types.ObjectId(req.params['member']);

console.log($.inArray(member_id, huntgroup.members));

can anyone tell me why ?

Warning: I am a newbie at mongoose, jquery and javascript, so go gentle 😉

  • 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-10T06:20:53+00:00Added an answer on June 10, 2026 at 6:20 am

    It’s because $.inArray is only checking for reference equality on the ObjectId objects.

    To compare the values of the ObectIds instead you’d need to use the equals operator of ObjectId by doing something like the following:

    huntgroup.members.forEach(function(member) {
        if (member.equals(member_id)) {
            // Yes, member_id is contained in the array
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this html @foreach (var item in Model.Options) { <input type=checkbox checked=checked name=selectedObjects
I have this: var SomeNamespace = { Model: Backbone.Model.extend(), View: Backbone.View.extend({ model: new this.Model,
I have this code and the following EF model: var modelToAdd = new Package
I have this model var Item = Backbone.Model.extend({ url: 'http://localhost/InterprisePOS/Product/loaditembycategory/Event Materials' }); var onSuccess
If i have this model: var myParentModel = Backbone.Model.extend({ defaults:{ parent1: null, parent2: null}
I have fit a simple bi-variate VAR model to this data set and I
I have code like this in my view model: function ChatListViewModel(chats) { var self
I have this model in django: class JournalsGeneral(models.Model): jid = models.AutoField(primary_key=True) code = models.CharField(Code,
Hello i have this following function: ... var model = $(#carModel); .... model.change(validModel); function
I have a code similar to this: My View @model MyCode.Models.RemarksModel foreach (var row

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.