How to search for "any" with .where() in firestore? [duplicate] - google-cloud-platform

This question already has answers here:
Conditional where clause in firestore queries
(2 answers)
Closed 3 years ago.
Is there a way to have an "empty" where query (that searches for anything).
Having
db.collection('skies').where('sky','==','blue')
right now I have to do
if (searchForAny){
db.collection('skies').otherStuff();
}
else {
db.collection('skies').where('sky','==','blue').otherStuff();
}

Is there a way to have an "empty" where query (that searches for anything)
Yes it is. To solve that, simply remove the call to:
.where('sky','==','blue')
When you are using the where() function, you tell Firstore to return only those documents where the sky property holds the value of blue. If you need all documents, use only a reference to the skies collection, not a query.

Related

Trigger cloud function when a specific condition resulting from the comparison of document fields in firestore is true [duplicate]

This question already has answers here:
Firestore Cloud functions | trigger events based on time field is equal to
(1 answer)
Is there a way to listen specific fields for firestore functions?
(1 answer)
Only checking if a certain property of a document has changed in cloud functions
(2 answers)
Closed 9 months ago.
In the observed document there are 2 fields that include timestamps, tsA and tsB.
tsA moves progressively closer to tsB until they eventually are the same - when this happens a cloud function shall be triggered, which performs a database operation in Firestore.
Is it possible to implement something like that - if so how?
No, you cannot trigger a function when a specific condition is met in Firestore. You can use onUpdate() trigger and then compare the values in the function itself.
If this operation doesn't need to be realtime then you can run a scheduled function (every few minutes/hours) that'll query for all documents where tsA and tsB are same and then process them.

Is there any function to edit a JSON file in Qt? [duplicate]

This question already has an answer here:
How to change values in a json file?
(1 answer)
Closed 1 year ago.
I have JSON file that contains some text, for example i have "Value": 39 and I want to change the value with for example 12. I know txts are not able to be modified but is there any method from json that does it for me?
Read the JSON file to QJsonDocument, then get the data container where you want to replace the value as QJsonObject and then create a new QJsonValue with the new value and then replace it in the container by calling https://doc.qt.io/qt-5/qjsonobject.html#insert . And finally write the Json document back to file.

What is an efficient way of inserting hundreds of records into an SQLite table using Django? [duplicate]

This question already has answers here:
Bulk create model objects in django
(10 answers)
Closed 1 year ago.
I have a CSV file with hundreds of data, I want to insert everything into my SQLite DB in my Django app. Inputting each value one by one will be a complete waste of time. What is a more efficient way to approach this?
The best approach in this case, is to use the bulk_create.
From the doc:
bulk_create(objs, batch_size=None, ignore_conflicts=False)
This method inserts the provided list of objects into the database in an efficient manner (generally only 1 query, no matter how many objects there are), and returns created objects as a list, in the same order as provided:
Link to doc:
https://docs.djangoproject.com/en/dev/ref/models/querysets/#bulk-create

How do I set the current selection in a QListWidget to none? [duplicate]

This question already has answers here:
How to clear the selection of QListView when multiple items are selected?
(2 answers)
Closed 4 years ago.
I have a list of items in a QListWidget and I want to make it so that when a certain action is performed the current selected item is deselected and no other item in the list is selected, like how the list appears when the program first starts.
I tried setCurrentItem(NULL); but that just creates a segmentation fault
Instead of changing the current item you need to clear the selection model. Here is how you do that:
selectionModel()->clear();

How to rename list of Excel sheets with a list of names [duplicate]

This question already has answers here:
Creating and Naming Worksheet in Excel VBA [closed]
(3 answers)
Closed 7 years ago.
I need to create profiles for a large list of clients. Each client has an ID number and I need to create a sheet in a workbook for each client, with the ID number for each client as the name for their respective sheets. I also have a sheet template that I would rather use to help create profiles in a uniform and professional manner. My question is: is there a way I can create a copy of the template for each of my clients and rename them with each of the ID's on my list, all at once?
The following VBA commands should cover what you want to do:
Rename a sheet
Sheets("Sheet5").Name = "Myname"
Add a sheet, then rename it
Sheets.Add
Sheets(ActiveSheet.Name).Name = "MyNewSheet"