find data from all field in single table mongodb [duplicate] - mongodb

This question already has answers here:
Mongodb text search multiple fields
(2 answers)
mognoose searching with regular expression in multiple columns
(2 answers)
Closed 5 years ago.
Hello I am new at mongodb , I have made server side pagination , working perfect, I have one search textbox in which I type anithing like email , name , number etc it should give me result but I am facting issue in serverside searching data from all field of single table , can anyone give me idea how can I do that

Related

Rename a MongoDB Collection [duplicate]

This question already has answers here:
MongoDB collection hyphenated name
(2 answers)
Closed 4 months ago.
I am trying to rename/drop, a Mongo collection where I have inadvertently put a . (dot) at the end of the DB collection name so the collection name looks like this:
collectionName.
I'm not able to find a way to use the collection name including the dot to either drop or rename the collection without getting an error back.
Any suggestions whether this is possible.
Check the docs
> use mytestdb
> db.orders.renameCollection( "orders2015" )

Mongodb string to date, problem with null values [duplicate]

This question already has answers here:
MongoDB: How to query for records where field is null or not set?
(9 answers)
Update MongoDB field using value of another field
(12 answers)
How do you query for "is not null" in Mongo?
(11 answers)
Closed 3 years ago.
I have a MongoDB (v 3.4.19) installed and running. After importing the data in .JSON format, one of the fields in the collection is recognised as string instead of the proper date or datetime format. I try to convert the fields, but what is my surprise after discovering that the fields with null values are filled with random (?) dates. I tried many different approaches, all of them without success. I wonder if any of you can give me a hand with this issue.
This is the code I have been using until now:
db.MIDAS_weather.find()
.batchSize(1000)
.forEach(function(doc) {
doc.METO_STMP_TIME=new Date(doc.METO_STMP_TIME);
db.MIDAS_weather.save(doc);
});
After importing the JSON files, the null values are in the right place. Is only after attempting the conversion when the data is messed.

How to fetch the data on the basis of multiple ids? [duplicate]

This question already has answers here:
Querying mongodb from golang using the _id stored in an array
(3 answers)
Find by id with mgo
(1 answer)
Closed 4 years ago.
Here I'm fetching the data from the database mongodb using golang. Suppose I have an Id attribute and i want to receive the data on the basis of this id and it was easy by passing the id attribute in the query like below:-
c.Find(bson.M{"_id": 1}).One(&data)
If the id is given 1. but I have an case that i have find two or more at one time on the basis of the ids that it will returns the array of the ids like "_id":[1,2,3] then How will I retrieve the data from that ids. Can anyone help for if.
EDITED
IS this question solve my problem.
Thanks

How can I apply a filter in MongoDB find operation to check empty string? [duplicate]

This question already has answers here:
Test empty string in mongodb and pymongo
(4 answers)
Closed 5 years ago.
I am working on a application built in PHP using MongoDB as a database.
Data is organized across BSON documents into a collection in MongoDB.
I need to retrieve only those documents where field containing string value is non empty value. I searched for functions equivalent to empty and strlen functions belonging to PHP language but did not get any relevant search results.
try this,
$cursor = $collection->find(array("someField" => array('$ne' => null)));

MongoDB only removing first field from the collection [duplicate]

This question already has answers here:
Why this update query only update one record once
(3 answers)
Closed 7 years ago.
I'm a beginner in MongoDb.I wanted to know what is the query to remove a field in Mongo DB Collection.I have tried with
db.Component.update({},{$unset: {vendor:""}}).
Its was updating only first document.So How to remove field Completely from Collection?
Try this-db.Component.update({},{$unset: {vendor:""}},false,true)
Here false