Dynamic method parameters - node.js

I writing a node.js application using rethinkdb as a backend.
To retrieve a json value you can use:
r.table('users').get(1).run()
That method call will return the full json document, there is however a method that allows you to specify the attributes to retrieve e.g:
r.table('users').get(1).pick('firstName', 'lastName').run()
I want to make use of this functionality and I have the attributes I want to 'pick' stored in an array. I can't seem to figure out a way to convert this array to a parameter list for the .pick method.
Please advice.

Just use the native apply method to directly pass the arguments array:
r.table('users').get(1).pick.apply(this,yourArray).run()
further reading

Related

How to develop a rest api without using serializer in Django Rest Framework?

I want to create a Student Register and Login Api without using serializer in django Rest Framework.
So I want to know how I make CRUD operation for those api using ApiView
Any one please solve this
I don't think you can, or even should but first, you need to understand what a serializer actually does:
Serializers allow complex data such as querysets and model instances to be converted to native Python datatypes that can then be easily rendered into JSON, XML, or other content types. Serializers also provide deserialization, allowing parsed data to be converted back into complex types, after first validating the incoming data
So don't be scared by serializers. Just take your time and learn how to use them using the many tutorials available online.
If you are using DRF then you must need to create the serializers. But you can create the API without using DRF and serialzers.
Serializer is not just for converting json data ,it also used to validate payload. You can use request.data.get("field_name_in_json_object") and fill the fields one by one.and for return you can use .values("field_name") in
querysets.
Django values_list vs values

Add Parameter Values to Query String of get request in ADF

I have a Copy Data task which is obtaining data from an API
The API is a GET call to a method and requires 2 parameters
_token
Symbols
I have defined these as parameters
What is the syntax that allows me to use the values of my parameters as the values that are in the query string? So in the screenshot above Symbols is hard coded, but I want the value to be the value of the parameters
I need a screen solution rather than code please as I am not comfortable with ADF yet and I dont know how to get to the code/ARM views
Paul
Using a feature called string interpolation where expressions are wrapped in #{ ... }
Click on the Base URL field. Add Parameters. Using Concat expression function,
Example:
#{Concat('https://stackoverflow.com/questions/GetRealTimeRates?',linkedService().Symbols,'=',linkedService()._token)}
Add first parameter:
Add second parameter:
Test connection. If you see any error, it would provide a description as to debug further.

Is it possible to use a calculated name of Azure API Management global property?

I need to retrieve the value of a global property. The name of the property comes from a request.
I would like to replace string 'ContosoHeader' in {{ContosoHeader}} with the parameter value from an incoming request. Is there a way?
Not at this moment, no. Only if number of such properties is limited you could use 'set-variable' to fetch them statically and then 'choose' to decide what value to use.
Alternatively you could try to store multiple values in single variable, storing JSON for example. This way you'll need to fetch only single known property.

How Can I Return a Random Object in Loopback?

I'm using loopback to build an application, and would like to write a custom remote method which returns a random model instance from the database.
Is there a way to do this using the built-in ORM?
Thanks!
There is no built-in way. You can do it manually depending on the type of data source you're using.
See https://groups.google.com/forum/#!searchin/loopbackjs/random/loopbackjs/C08v1K0NKHk/8nUp9VSGEhEJ

JSF: How do I include parameters in an action method's return string?

I'm writing an action method that will store a new object in a database. Once this is done, I want to navigate to view that newly created object. To do this, I was planning to include a querystring or some sort of parameter in the return String of the action method, but I can't figure out how. If I append a query string manually, it appears that it's being ignored. Also, manually adding parameters by concatenating strings doesn't seem like a good idea to me. Is it possible to do this in a type-safe manner?
The way I've always handled this is to get a reference to the bean which provides the content for the page you'll be displaying, and just set its properties directly. The navigation string returned from an action method isn't meant for passing parameters, but you don't need it to; all they'd be used for is setting bean properties anyway.

Resources