Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
578 views
in Technique[技术] by (71.8m points)

mongodb - Mongo db : data uploaded using CSV has Null stored as String in Mongo document

I tried uploading data into Mongodb using CSV from Mongodb Compass. In the CSV, some of the fields have Null values stored in them. But, after uploading those fields in Mongo, documents have "Null" stored as String. Is there a way to store Null fields from CSV with the type Null?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can correct easily later:

db.contacts.update({a:"Null"}, {$set: {a: null}},{multi:true} )

or you can remove those fields from the document:

db.contacts.update({a:"Null"}, {$unset: {a:1}},{multi:true} )

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...