Monday, May 30, 2022

MongoDb and C sharp

 Base Repository

https://drive.google.com/file/d/1-2M7YotJQ1Q31XZB32l8nt70wbqnCE7t/view?usp=sharing

Tuesday, May 24, 2022

Mongo db query

 Query

> use s27_events


  1. SELECT * FROM Profile

    db.Profile.find ({})

  2. SELECT * FROM Profile WHERE Name = "Chamith"

    db.Profile.find({Name:"Chamith"})

  3. SELECT * FROM Profile WHERE Name = "Chamith" AND Dob = "1988-01-24" AND Setting.Security._2fa = false

    db.Profile.find({Name:"Chamith",Dob:"1988-01-24",Setting:{Security:{_2fa:false}}})



Update

update/add a new field to the collection


db.Profile.update({},{$set:{ProfileImage:"chamith.png"}})

db.Profile.update({},{$unset:{ProfileImage:"chamith.png"}})

db.Profile.update({},{$set:{ProfileImage:[{Url:"chamith1",IsDefault:false},{Url:"chamith2",IsDefault:true}]}})

db.Profile.update({},{$set:{Setting:{Security:{ _2fa:false}}}})

db.Profile.update({_id:ObjectId('628cae92a72e5e4316a8a8a5')},{$set:{Setting:{Preferences:{Country:"Sri Lanka",Currency:"LKR"},Security:{_2fa:true}}}})




CS Events