I access CouchDB (3.3.2 on Windows) from a Node application (written in typescript) through the application API.
It works perfectly when I load the db in batch and then, after some time, I search and retrieve the documents.
But for testing I create two documents in db through the application API, then try to retrieve them. Sometimes they are returned, sometimes only the first or second one are retrieved.
I tried to put a delay between creation and retrieval, but seems it does not help (or maybe I have waited too little). Or maybe the indices are not updated yet for the search and retrieval, or I don't know.
Is there any way to wait till or to known when the creation finished? It is needed only for testing.
Thanks in advance!
mario
Related
Let's say, hypothetically, I am working on a website which provides live score updates for sporting fixtures.
A script checks an external API for updates every few seconds. If there is a new update, the information is saved to a database, and then pushed out to the user.
When a new user accesses the website, a script queries the database and populates the page with all the information ingested so far.
I am using socket.io to push live updates. However, when someone is accessing the page for the first time, I have a couple of options:
I could use the existing socket.io infrastructure to populate the page
I could request the information when routing the user, pass it into res.render() as an argument and render the data using, for example, Pug.
In this circumstance, my instinct would be to utilise the existing socket.io infrastructure; purely because it would save me writing additional code. However, I am curious to know whether there are any other reasons for, or against, using either approach. For example, would it be more performant to render the data, initially, using one approach or the other?
I have a basic Nodejs server connected to my ios App and firebase client. I want to fetch data from the database, which is in and system generated alphanumeric format(ex: -ibdUKV6168ded). I obviously cannot input that manually every time theres such entry, also I dont want to fetch it by having an index number of the array. How can I fetch that key.
Plus, Every time such key is generated, i want to read the document present in it.
I am out of ideas.
Any help will be much appreciated.
The database looks like this:
I want to fetch the post keys explicitly. I have a on() event called each time a new post is generated. How can I reference them.
This is solved by the firebase functions. Although, they are in beta, they are a great help. Functions along with Admin SDK provide really great combination to deal with such querying of data, where the values are uniquely identified.
We are observing that there are three API calls happening when we execute an offline sync selective pull query
GET domain/tables/Events?$filter=updatedAt%20ge%20datetimeoffset'1969-12-30T22:00:00.000Z'
GET domain/tables/Events?$filter=updatedAt%20ge%20datetimeoffset'2017-06-27T22:00:00.000Z' (current datetime)
GET domain/tables/Events?$filter=updatedAt%20ge%20datetimeoffset'2017-06-27T22:00:00.000Z'&$skip=1
These 3 calls happen every time a pull is done, can anyone explain why this happens? The selective sync query is created in the following format
syncContext
.pull(new WindowsAzure.Query('Events'), 'eventspull')
.then(function() { /* pull complete */ });
We are using latest version of the following javascript offline library. https://zumo.blob.core.windows.net/sdk/azure-mobile-apps-client.js
These 3 calls happen every time a pull is done, can anyone explain why this happens?
This happens because the "pull" function pulls one page from the server table at a time. You can check out the source code here for details.
Let’s say you have thousands of records. If you execute the query without paging, then it is likely you will tie up your client process on the phone for a considerable period of time as you receive and process the data. To alleviate that and allow your mobile application to remain responsive, the client SDK implements paging. By default, 50 records will be requested for each paged operation. In reality, this means that you will see one more request than you expect.
For more info, pelease refer to Understanding offline sync.
I've been working on a Xamarin.Forms application in Visual Studio using Azure for the backend for a while now, and I've come across a really strange issue.
Please note, that I am following the methods mentioned in this blog
For some strange reason the PullAsync() method seems to have some bizarre problems. Any data that I create and sync will only be pulled by PullAsync() from that solution. What I mean by that is that if I create another solution that accesses the exact same backend, it can perform it's own create/sync data, but will not bring over the data generated by the other solution, even though they both seem to have the exact same access. This appears to be some kind of a security feature/issue, but I can't quite make sense of it.
Has anyone else encountered this at all? Was there a work-around at all? This could potentially cause problems down the road if I were to ever want to create another solution that accesses the same system/data for whatever reason.
For some strange reason the PullAsync() method seems to have some bizarre problems. Any data that I create and sync will only be pulled by PullAsync() from that solution.
According to your provided tutorial, I found that the related PullAsync is using Incremental Sync.
await coffeeTable.PullAsync("allCoffees", coffeeTable.CreateQuery());
Incremental Sync:
the first parameter to the pull operation is a query name that is used only on the client. If you use a non-null query name, the Azure Mobile SDK performs an incremental sync. Each time a pull operation returns a set of results, the latest updatedAt timestamp from that result set is stored in the SDK local system tables. Subsequent pull operations retrieve only records after that timestamp.
Here is my test, you could refer to it for a better understanding of Incremental Sync:
Client : await todoTable.PullAsync("todoItems-02", todoTable.CreateQuery());
The client SDK would check if there has a record with the id equals deltaToken|{table-name}|{query-id} from the __config table of your SQLite local store.
If there has no record, then the SDK would send a request as following for pulling your records:
https://{your-mobileapp-name}.azurewebsites.net/tables/TodoItem?$filter=(updatedAt%20ge%20datetimeoffset'1970-01-01T00%3A00%3A00.0000000%2B00%3A00')&$orderby=updatedAt&$skip=0&$top=50&__includeDeleted=true
Note: the $filter would be set as (updatedAt ge datetimeoffset'1970-01-01T00:00:00.0000000+00:00')
While there has a record, then the SDK would pick up the value as the latest updatedAt timestamp and send the request as follows:
https://{your-mobileapp-name}.azurewebsites.net/tables/TodoItem?$filter=(updatedAt%20ge%20datetimeoffset'2017-06-26T02%3A44%3A25.3940000%2B00%3A00')&$orderby=updatedAt&$skip=0&$top=50&__includeDeleted=true
Per my understanding, if you handle the same logical query with the same query id (non-null) in different mobile client, you need to make sure the local db is newly created by each client. Also, if you want to opt out of incremental sync, pass null as the query ID. In this case, all records are retrieved on every call to PullAsync, which is potentially inefficient. For more details, you could refer to How offline synchronization works.
Additionally, you could leverage fiddler for capturing the network traces when you invoke the PullAsync, in order to troubleshoot your issue.
I have an nodejs server running witch show data on a web interface. The data is fetched from a MongoDB using mongoose. The data is added via an node-red application witch is isolated from the rest.
Currently my nodejs server fetches the data every 5 seconds. Is there a way to know if the data in my MongoDB has changed?
Thanks, I hope my question is clear.
I was also looking for something similar to what you are asking for few months back. Few ways which i know to do it are:
1) You can try to use middlewares while inserting your documents in DB. You can then send that new data either after saving it in DB or at the time of insertion only.
2) Refer to this answer which talks about solving your problem using inbuilt functions provided by mongoDb. You can study in deep about them in mongoDb docs.
3) There is also another way to do this which includes listening to changes in log files. As you know everything done in mongo is recorded and logged in files so whenever there is some change in data you can know it from there also. You will have to do the digging by yourself in this method.
Hope it helps!