Ir al contenido principal

Entradas

Mostrando las entradas etiquetadas como coding

How to delete one or more documents from your MongoDB repository

MongoDB seems to be complex at first sign, but in fact is not, you could perform a complete CRUD easily if you expend some time on the documentation. For example, lets say you need to delete some documents (rows, if you are thinking on a traditional RDBMS). First you want to find all these documents to be removed. > db.your_collection.find({ "cvectry": "MX", "layer_id": 20 }, {}) { "_id" : ObjectId("5e8123e8892355c921e6b436"), "layer_id" : 20 } > After finding all these documents to be removed, then you want to perform the following delete method as follow: > db.your_collection.remove({ "cvectry": "MX", "layer_id": 20 }, { justOne: true }) WriteResult({ "nRemoved" : 1 }) > In this case, after finding all these documents that match with "cvectry": "MX", "layer_id": 20. I got the result on the first command I ran, so I just wanted to delete just on...

I have been playing with pdb for debugging code (introductory level)

Well, this is time to talk about something I have been playing, the pdb standard module python provides. I'll talk in the context of py 3.7+ since there are differences that improve how to work with this. Well, first of all, as you should found in this field and coding experiences and challenges. You have to deal with bugs, unexpected errors, or even worst, unexpected behavior which sometimes is most difficult to trace. Here are some lights on how to use it, this is really useful if your life is coding :). Consider the following commands table. Command Description s Execute the current line and stop at the first possible occasion. n Continue the execution until the next line in the current function is reached or it returns. p Shows the values of variables in context code. ll List the whole source code for the current function or frame l In contrast to ll, this command shows a shorter snippet of code. l. If you pass the param . to this command, it will show you always 11 li...