I am using kendo grid to which data is provided by kendo data source. I am using quite a complicated filter and thats why I have to use parameterMap function to do some sorting and filtering. When the query is sent, the query string is automatically prepared by the data source and everything works fine. I need a way to store this url (at least the query string) for every read request. Is there a way to access it?
After some research... that was pretty easy. It is enough to use decodeURIComponent before returning data in the parameterMap function:
parameterMap: function (data, operation) {
...
storeSomewhereTheValueOf(decodeURIComponent($.param(data)));
return data;
}
Related
I'm new to GraphQL. I have a server API that only returns changes done to a list of objects since a certain timestamp given by the client. This is for performance reasons - so that polling will return a smaller result after the initial query. So the first query result would be something like:
{
data: [fullobj1, fullobj2, fullobj3, ...],
timestamp
}
and a subsequent query is sent with the previous query's timestamp would result only with objects that changed, and only the fields that changed in them:
{
data: [partialobj1, partialobj3],
timestamp
}
Since I define this in GQL as a "query", Apollo has no way of knowing that I want the results to merge rather than replace one another. What is the "proper" way of implementing this using Apollo client? (I'm using the React variant)
I am using wagtail's get_search_backend.search to fetch data.
If the query string provided is empty, the use case for us is to return all the data.
Is there a way to achieve it?
I'm looking to search for a particular JSON document in a bucket and I don't know its document ID, all I know is the value of one of the sub-keys. I've looked through the API documentation but still confused when it comes to my particular use case:
In mongo I can do a dynamic query like:
bucket.get({ "name" : "some-arbritrary-name-here" })
With couchbase I'm under the impression that you need to create an index (for example on the name property) and use startKey / endKey but this feels wrong - could you still end up with multiple documents being returned? Would be nice to be able to pass a parameter to the view that an exact match could be performed on. Also how would we handle multi-dimensional searches? i.e. name and category.
I'd like to do as much of the filtering as possible on the couchbase instance and ideally narrow it down to one record rather than having to filter when it comes back to the App Tier. Something like passing a dynamic value to the mapping function and only emitting documents that match.
I know you can use LINQ with couchbase to filter but if I've read the docs correctly this filtering is still done client-side but at least if we could narrow down the returned dataset to a sensible subset, client-side filtering wouldn't be such a big deal.
Cheers
So you are correct on one point, you need to create a view (an index indeed) to be able to query on on the content of the JSON document.
So in you case you have to create a view with this kind of code:
function (doc, meta) {
if (doc.type == "youtype") { // just a good practice to type the doc
emit(doc.name);
}
}
So this will create a index - distributed on all the nodes of your cluster - that you can now use in your application. You can point to a specific value using the "key" parameter
I have a webservice that returns DataTable, but instead of it I want to return a list. Is there a way to return a list directly from SQL or I would have to return it as a DataTable and then transform it to a list?
What you want to do is convert each row in your DataTable to an object.
Here is a nice blog post that shows a helper class for this: Converting Custom Collections To and From DataTable
The idea is that you loop trough all your rows and then use reflection to create the objects. You do this by mapping each column name to a corresponding property name.
You can also use Linq to DataSet to run a Linq query against your DataTable. In Linq you can then use Projection to transform your data into a new type.
Here are some examples: Query Expression Syntax Examples: Projection (LINQ to DataSet)
I'm trying to write a couchdb view that takes a created_at timestamp in a sortable format (2009/05/07 21:40:17 +0000) and returns all documents that have a greater created_at value.
I'm specifically using couch_foo but if I can figure out how to write the view I can create it in futon or in the couch_foo model instead of letting couch_foo do it for me.
I've searched all around and can't figure out the map/reduce to do this, if it's possible.
This is the kind of problem I ran into initially before I fully understood how views work.
The key to the understanding is that the view is only run once for each (revision of) a document. In other words, when you query a view, you don't run the function, you simply look up the results of when the function ran. As such, there is no way to pass any user-submitted parameters into a view.
How then to compare a value in a view with a user-submitted value? The secret is to emit that field as a key in the map function and rely on letting couchdb order by the keys.
Your map function would be something like
"map" : "function(doc) { emit(doc.created_at, doc); }"
and you would query it like so:
http://localhost:5984/db/_design/ddoc/_view/view?startkey=%222009/05/07%2021:40:17 +0000%22
I have taken the liberty of uriEncoding the quotes and spaces in the url so that it should be usable as is.
You want to write a view that creates a key of the timestamp field in that format, then query it with the startkey parameter.
So the view would look something like:
"map" : "function(doc) { emit(doc.timestamp_field, doc) }"
And your URL would be something like:
http://mysever/database/_design/mydoc/_view/myview?startkey="2009/05/07 21:40:17 +0000"
The HTTP view API page on the Wiki has more info. You may also consider the User Mailing List.
Please mind that couchdb works only on json values. If the timezone if the document stored in couchdb is different to the timezone of your startkey the query likely will fail.