mongoDB - Add a boolean field "capital?" to all pertaining to ALBANY NY

 
Vista:

Add a boolean field "capital?" to all pertaining to ALBANY NY

Publicado por Leo (1 intervención) el 05/03/2021 16:56:02
Objective:

Add a boolean field "capital?" to all documents pertaining to ALBANY NY, and
New York, NY. The value of the field should be true for all Albany documents
and false for all New York documents.


I've tried for the 1st part of the problem ("zips" is my collection down here):


1
db.zips.updateMany({"city":"ALBANY"}, {"$set":"capital?"}, {upsert: false, multi, true})


result:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{
	"_id" : ObjectId("5c8eccc1caa187d17ca6ed1e"),
	"city" : "ADGER",
	"zip" : "35006",
	"loc" : {
		"y" : 33.434277,
		"x" : 87.167455
	},
	"pop" : 3205,
	"state" : "AL",
	"capital?" : {
 
	}
}
{
	"_id" : ObjectId("5c8eccc1caa187d17ca6ed1f"),
	"city" : "ADAMSVILLE",
	"zip" : "35005",
	"loc" : {
		"y" : 33.588437,
		"x" : 86.959727
	},
	"pop" : 10616,
	"state" : "AL",
	"capital?" : {
 
	}
}
etc... it adds "capital?{} to to every city not just ALBANY !!!!

HOW DO I FIX THIS??????

THANKS
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder