How can we get request values from body in couchbase - couchbase

I want to write design document that contain views, and in the view i need to get values from body. I done like this in couchdb using list. But i don't know how to achieve the same in couchbase.
Currently i write the value in view directly.
`function (doc, meta) {
if(doc.name!='anoop'){
emit(doc.name, [doc]);
}
}`
I need to replace that value by getting through body.

couchbase does not support lists, only views. and you cannot pass vales to the mapper just because at the query performed to after index built and stored to the disk
you can try N1QL http://www.couchbase.com/communities/n1ql

Related

How to return dynamic sql data as JSON in spring boot

What is best Java based approach to return dynamic data as JSON to front end ? Example : API call return 10 columns and their values but that can change to 20 columns in next API call.... looking for best rest API approach. thanks
I though of keeping queries in database table, pick up from there and take it as collection and return as JSON. whenever there is change in query then update the query with modified columns

Apache Beam PubSubToBigQuery.java duplicate removal?

I am using PubSubToBigQuery.java code without any changes. Would someone please show me how to remove duplicate records during this process?
I know the trick is to create Window and use GroupBy but really not know how to write it.
Thanks
Assuming you just want to filter duplicate on successful parsed events. You will need to add some code after this line:
transformOut
.get(TRANSFORM_OUT)
.apply("keyed", WithKeys.of(/* choose your key from table row to identify duplicates */))
.apply(GroupByKey.create())
.apply("dedup", ParDo.of(new DoFn<KV<String, Iterable<TableRow>>, TableRow>() {
public void ProcessElement(ProcessContext context) {
// only output one element from list to dedup.
context.output(context.element().getValue().iterator().next());
}
}
))
.apply(Window.configure().triggering(/* choose your trigger */)
.apply(
"WriteSuccessfulRecords",
BigQueryIO.writeTableRows()
.withoutValidation()
.withCreateDisposition(CreateDisposition.CREATE_NEVER)
.withWriteDisposition(WriteDisposition.WRITE_APPEND)
.to(options.getOutputTableSpec()));
BeamSQL actual tries to support your use case (check PubsubToBigqueryIT.java). BeamSQL allows you create table on pubsub topic and bigquery table. Read from pubsub, convert pubsub messages and write to BQ table are handled by BeamSQL already. SQL can be applied to data that read from pubsub. However, BeamSQL might miss some features (for example, ANY_VALUE aggregation function if you want use group by to dedup in SQL) to finish your task.

Fetch values in deeper nodes in Firebase Database

How can I get data in the nodes in the nodes like "01_01_2017_01_00_AM" which are dynamic and even there are multiple children with auto generated push IDs. I need to process results matching the current date in the above format and then display.
By the way I am working with Firebase and Cloud Functions.
Database preview
You can only query one level at a time in Firebase.
You could do a query like this if you know the mail_data key.
admin.database().ref('mail_data/e...IG2')
.orderByKey()
.equal to('01_01_2017_01_00_AM')
.once('value')
.then(snapshot => { ... });
Which would get you the snapshot of your object.

ServiceNow - JSON Web Service, display related tables

I'm working on a C# program that retrieves data from a ServiceNow database and converts that data into C# .NET objects. I'm using the JSON Web Service to return my data in JSON format.
What I want to achieve is as follows: If there is a relational mapping between a value (for
example: I have a table called Company, where CEO is not a TEXT field but an sys_id to a Employee Table) I want to be able to output that data not with an sys_id (or just displaying the name property by using the 'displayvariable' parameter) but by an object displayed in JSON.
This means that the value of a property should be an object in JSON instead of just a single value.
A few examples:
// I don't want the JSON like this
{"Company":{"CEO":"b181e841c9212c008aeb36850331fab2"}}
// Or by displaying the name of the sys_id table
{"Company":{"CEO":"James Henderson" }}
// I want the data as follows, so I can have all the data I need inside a single JSON record.
{"Company":{"CEO":{"name":"James Henderson", "age":34, "sex":"male", "office":"SBN Left Floor 23"}}}
From reading the documentation I couldn't find anything in the JSON Web Service that allowed me to display the information like this nor
find any other alternative. It should have something to do with joining the tables and displaying it all in the right format.
I have been using SNC for almost three years and have not found you can automatically join tables in a web service. Your best option would be to use a scripted web service which possibly takes a query parameter and table parameter. Then you can json serialized your result as you see fit.
Or, another option would be to generate a new processor that will traverse the GlideRecord object. The ?JSON parameter you pass in to the URL is merely a flag to pass your request to a particular processor. Unfortunately the OOB one I believe is a Java class not a JS script, so you would need to write a script much like I mentioned earlier to traverse the object path serializing the object graph as far down as your want to go.

How to query a Lotus view and have the result formatted as json?

I have a view called 'walking' which I want to query:
http://site/activity.nsf/walking?searchview&query=FIELD%20Gradient%20CONTAINS%20gradienteasy.gif
This returns the results in an HTML table. What I would like to do is have the results formatted as JSON which I will then use client-side. Is this possible?
I know you can get JSON returned from a straight view by doing this:
http://site/activity.nsf/walking?readviewentries&outputformat=json
Scott Good and I have done several sessions at a variety of conferences on generating and consuming JSON from traditional Domino applications (not using XPages). The most recent was the "JMP303 JSON in client- and server-side code Master Class" we gave at Lotusphere 2011. Link to the presentation materials and slides are: here
/Newbs
You will have to create a view that is marked with the "Treat view contents as HTML" property and set up a column formula that generates the JSON syntax that you want'.
There is a nice post on OpenNTF with the code to create a very generic view which returns JSON for the documents that match the View's selection formula:
http://openntf.org/XSnippets.nsf/snippet.xsp?id=use-transform-to-build-json-and-consume-the-output-in-an-xagent
That sample uses an "XAgent" (Xpage with no UI) to set the content-type header, etc. But you could probably do the same thing using a $$ViewTemplate form, if needed.