Skip to content
Advertisement

mongodb wrong members id

I’m trying to change the priority of the members of the replica set:

cfg = rs.conf();

output:

JavaScript

}

cfg.members[5].priority = 0.5

JavaScript

cfg.members[4].priority = 0.5

JavaScript

but id:3 change normaly:

cfg.members[3].priority = 0.5

JavaScript

what am I doing wrong? And why my version of the config too big? So many times that I couldn’t change the configuration)

Advertisement

Answer

You should address to elements of list members, not using _id property. So it will be cfg.members[0], cfg.members[1], etc

To filter by _id I think u need to use

cfg.members.filter()

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement