তালিকা ক্ষেত্রের ক্যোয়ারী বুঝতে, এবং/অথবা, আপনি নথি সহ একটি সংগ্রহ তৈরি করতে পারেন।
একটি নথির সাথে একটি সংগ্রহ তৈরি করার প্রশ্নটি নিম্নরূপ -
> db.andOrDemo.insertOne({"StudentName":"Larry","StudentScore":[33,40,50,60,70]});
{
"acknowledged" : true,
"insertedId" : ObjectId("5c9522d316f542d757e2b444")
}
> db.andOrDemo.insertOne({"StudentName":"Larry","StudentScore":[87,67,79,98,90]});
{
"acknowledged" : true,
"insertedId" : ObjectId("5c95230916f542d757e2b445")
} Find() পদ্ধতির সাহায্যে একটি সংগ্রহ থেকে সমস্ত নথি প্রদর্শন করুন। প্রশ্নটি নিম্নরূপ -
> db.andOrDemo.find().pretty();
নিচের আউটপুট −
{
"_id" : ObjectId("5c9522d316f542d757e2b444"),
"StudentName" : "Larry",
"StudentScore" : [
33,
40,
50,
60,
70
]
}
{
"_id" : ObjectId("5c95230916f542d757e2b445"),
"StudentName" : "Larry",
"StudentScore" : [
87,
67,
79,
98,
90
]
} এখানে তালিকা ক্ষেত্রের প্রশ্ন রয়েছে৷
প্রশ্নটি নিম্নরূপ -
> db.andOrDemo.find({"StudentScore":70}).pretty(); নিম্নলিখিত আউটপুট:
{
"_id" : ObjectId("5c9522d316f542d757e2b444"),
"StudentName" : "Larry",
"StudentScore" : [
33,
40,
50,
60,
70
]
} কেস 3 − এখানে বা তালিকা ক্ষেত্রের জন্য ক্যোয়ারী আছে।
প্রশ্নটি নিম্নরূপ -
> db.andOrDemo.find({"$or":[ {"StudentScore":60}, {"StudentScore":90}]}).pretty(); নমুনা আউটপুট -
{
"_id" : ObjectId("5c9522d316f542d757e2b444"),
"StudentName" : "Larry",
"StudentScore" : [
33,
40,
50,
60,
70
]
}
{
"_id" : ObjectId("5c95230916f542d757e2b445"),
"StudentName" : "Larry",
"StudentScore" : [
87,
67,
79,
98,
90
]
}