How to update individual array element in firebase with iOS Swift? - ios

Here i'm using firestore query to update, insert data. How to upadate dictionary of array value to firebase database.
here is my firestore data structure:
Right now able to get data of slot1 -> 0th position value in a model class.
how can i update value of slot1 0th position of isbooked boolean value alone, without affecting remaining values and other slot.

You can't without reading the entire document, modifying the array data in memory, then updating the entire array field back out do the document. The smallest unit of change in a Firestore array field is an entire field. You can't make smaller changes to individual elements of a field, except those defined by arrayUnion and arrayRemove (which are not compatible with what you're trying to do here).

You can do that by getting the exact id of your structure ..
Database.database().reference().child("SlotName").child(yourAry.key).child(yourAry.key).child("isbooked").setValue(true/false)
Manage your database structure accordingly, its just an example and as user Doug suggested have a look on docs too ..

Related

Align imported Data with manually added data

Example File: https://docs.google.com/spreadsheets/d/1Ht_2QMGMbHmlxSPoOiLX2vw78IL1wp3VhpOOc66eMqY/edit#gid=0
We are filling Point 1 - 4 manually. The data in A,B,C is sorted through C and will change every now and then. The problem I am noticing now is that A,B,C is moving. But D:G will stay in the same column.
We want to use this file to fill in the data since its our main file. So using the initial =query to also take into account D:G is not an option.
Would there be any other way to "link" D:G to the corresponding values in A:C?
Looking at your sheet I noticed you try a VLOOKUP formula.
Please try the following formula
=INDEX(IFERROR(VLOOKUP(A1:A;Blad1!A2:I;{6\7\8\9};0)))
Of course your approach would cause problems. You're trying to map manual data to some data that is bound to change. You can't expect the manual data to move or change in sync when the imported data changes.
You could probably make it work at least if the imported data does not change in order, and instead gets any new data appended. Even then, it doesn't help you if any of the imported rows gets deleted.
There are only two ways I could see to make this work:
Map your manual data as part of the original sheet where your other data is imported from. In other words, make D:G part of the source of A:C, if possible. This is the best approach. Works even when some imported rows get deleted or changed.
Don't sort A:C at source. Simply append new rows, and import as is. Keep your Blad1 sheet as the local source sheet, and add your manual data to D:G here. Then create a new sheet for sorting or do any other thing you'd like, and use this new sheet to feed your Blad2 sheet. This doesn't work if some of the imported rows get deleted or changed.

Firebase get more data with queryLimitedToLast

I've a simple chat in swift and I retrieve 10 elements with queryLimitedToLast.
I want retrieve more element with a refresh function. How can increase the number of elements?
I've try to set the value in queryLimitedToLast with a variable but don't works.
Thanks!
Firebase Queries are immutable; once you've created them, you cannot modify them.
So you'll have to create a new query, which starts at the end of the previous query.

Delphi Combo Edit from CSV File

I have an application that will load a CSV file containing two columns. At program load I need to have the first column as items in a combo edit control. Once the user selects (or enters a value) I need to populate a label with the value from the second column. My thought was to use an in memory data set, FDMemTable which would be loaded at form create. Then once the user selects, or enters an item, I would run a query to pull the description. I've tried but have been unsuccessful with the simple loading of the combo edit.
Is this the best way to achieve the desired results, and is there samples similar to what I'm looking to do?
Read the file.
Parse it into an array of name/value pairs.
Populate the combo drop down list with the names.
When the combo's selection is changed to a new index, read the value from the array using that index. Update the label.
Database tables and queries seem somewhat over the top for a single simple task like this.

Get Range of Cells Value as Display using Microsoft.Office.Interop.Excel

I am programming with C# to access data from a range of cells in Excel Spreadsheet.
I can use the following code to access and return the values of range of cells into an object array.
(object[,])Mysheet.UsedRange.get_Value(XlRangeValueDataType.xlRangeValueDefault);
However, I like to find a mean to return all data as strings (exactly as shown on the spreadsheet) into a string array or putting the values as text into the object array. Are there any mechanism to do that>
Did you try using .Text in the Range object? As far as I know, you will have to iterate over each cell and do it for each of them.
Note that .Text is considerably heavy in terms of performance compared to Value or Value2.
And also note that it is also tricky, .Text returns the text as you would see it if you had Excel visible, so if you have a huge number in a column with a short width what .Text will give you is a lot of ####
Sadly I can't think of another way to get it. Usually I get the raw values and format them properly once a get them all, but that assumes that I know which format is used in which cells.

Storing the (array data)session in core data iOS

In my application I have seven category button on firstController which open secondController(tableView) having arrays of question. This question are in tableView which having Yes, NO buttons option for check/uncheck marks. Selecting Yes-No option will change the colour of tableView row. After answering the question the user can generate audit report(1st session). This report is usually PDF file. I am printing all the checked question on the PDF page and saving.
I have used NSUserDefault for saving all the array of checked question and NSDocumentDirectory for saving PDF file. In the current scenario, the User has to reset all the thing before he want to work for the second audit report(second session).
Now customer want the flexibility to save 1st incomplete audit report in database and would like to go for completing second audit report. Hence he can complete 1st audit report later and so on...
I have never used Core Data before, hence will the core data help me in above scenario. How can I apply logic here from scratch. Can some one give me the better idea. thanks in advance.
Edited with Explanation
I have 400 question array list taken in tableView with check/uncheck button. But for audit, user can checked question by his wish. say 100 question he checked so that he would save 100 question and print as a PDF pages.
User would like to have chance to save all incomplete session of checked-unchecked question to access it later to convert this as a PDF file.
Which method will be better?
If you just have an array or booleans or identifiers for your selected rows, don't use Core Data. Instead, just save the array to disk using writeToFile:atomically: and read it back in when required using initWithContentsOfFile:. You only want to consider Core Data if you want to store more information.
You can also have an array of dictionaries. Store the whole thing, not just the edited values (to make indexing easy). Colours are interesting. You could encode them into strings as comma separated rgb values or use an archived to convert them into data. You can't directly put the colours into a plist. You could put the colours into core data as transformable.

Resources