What does a genre id "-1" mean? - deezer

At this moment, a search for http://api.deezer.com/search/album?q=Big%20Sean%20Bounce%20Back, will have some results with a genre_id or -1.
Is there a specific meaning to this 'id'?

Related

Concatenate 2 integers to an integer MongoDB

I have a scraped some sports data, which contains an id field that ideally I'd like to use as Mongo's "_id". It's event based data and the IDs are meant to be unique however there is a few cases where they are not. However each entry also has a match id value, which is unique. There is never duplicated event IDs for the same match id. I was looking for a way to concatenate the two fields to create a unique id value that I could then use as the "_id" but this doesn't seem possible. I tried using the $concat operation with $tostring however this results in values such as 54821.4e+09
For example, a document with match id 3181621 and event id 1339018347 using
{$project:{"new_id":{$concat:[{"$toString":"$matchId"},"",{"$toString":"$id"}]}}}
results in "new_id" : "3181621.33902e+09", when I would want it to be 31816211339018347

Find documents with a certain field value only when another field value is a given string

I'm using this php package to make queries - https://github.com/jenssegers/laravel-mongodb
The situation is, there are two fields, user_id and post_status among others. I want to retrieve all the documents in that collection, but when post_status field value is draft, that should be retrieved only when user_id is a given string. The idea is, only logged in user finds their drafted posts among other posts.
I'm having hard time finding any solution for this problem. The app is still not in production. If I should store data is some different manner, that is an option as well.
Find documents with a certain field value only when another field value is a given string
The question your are framing is simply convert into a and query, how let's see it
when another field value is a given string
This means that you have some result sets and you need to filter out when user_id match with some string. i.e some result sets and user_id = <id>
Now consider the first part of the sentence Find documents with a certain field value
This means you are filtering the records with some values i.e "status" = "draft" and whatever result will come and want again to filter on the basis of user_id = <id>
So finally you will end-up with below query:
db.collectionName.find({"status":"draft", "user_id": "5c618615903aaa496d129d90"})
Hope this explanation will help you out or you can rephrase your question I will try to modify by ans.

Mongo distinct query returns several records one of which is "". But find null fails to find it

I ran a distinct query on a collection. The query syntax:
db.Collection.distinct("dict.field")
I got a set of results - one of which was "" (null).
I then tried to find the record that had a null value for the field in question:
db.Collection.find({"dict.field": null})
To my surprise, no record was found.
No indexes are set on this collection other than _id.
The field in question is a dictionary.
What am I missing?
You should look for db.Collection.find({"dict.field": ""}) instead. Null and String ("") are considered different datatypes.
https://docs.mongodb.com/manual/reference/bson-types/

MongoDB sort by only exists entry, key with value first and key with null or not exists last

I have a collection of 15000 documents. Some documents have sr_no with numeric values and other with absent of sr_no.
Now i want to get entries like all documents comes first which has sr_no with asc then all others.
I tried .find().sort({sr_no:1}) but it return all null entries first then asc with sr_no.
This question seems too close with duplicate. But slightly defer
with numeric key.
I answered it with hack below.
I used a dirty hack for this.
MongoDB doc says that they have priorities for sorting as posted below image.
So when i sort with asc then it sort first all null (empty key consider as null) entries then sort numeric entries.
What is hack here ?
Store sr_no : "" with empty string default.
Now it will sort first numeric values then string.

Mongodb query forward from username X

I have problem whit long Mongo find results. Example how can i start query starting from _id X
to forward Example I know I have document where is 1000 users details I know there is user called Peter in list I can make query Users.find({userName: "Peter"}) and get this on user _id but how I can get all users also after this with out I need return JSON from above "Peter"
With the little amount of information you have given, You need to do this in two steps:
Get the id of the first record that matches the name "peter".
db.test.findOne({"userName":"Peter"},{"_id":1});
Returns one document that satisfies the specified query criteria. If
multiple documents satisfy the query, this method returns the first
document according to the natural order which reflects the order of
documents on the disk. In capped collections, natural order is the
same as insertion order.
Once you have the id of the record with peter, you can retrieve the records with their id > the id of this record.
db.test.find({"_id":{$gte:x}});
Where, x is the id of the first record returned by the first query.