can you tell me how to make
DB::table()->where()->get() result into a JSON script?. In this script I want get a row as a result
DB::table('users')->get()->toJson() should be enough. Ref docs
If you are making API, use Eloquent resource.
Related
I have one table which contains json string column ,i want to search inside the json column for that i am using whereJsonContains method but still it’s showing empty records but the data is there .did i miss anything .
$id=98; $reqid=7; Table::whereJsonContains(“json_data->”.$id ,$reqid)->get();
My json data is {“94”:”3”,”98”:”7”}
I was trying to fetch that column data and make it an array but it’s taking more time to execute so i want to do in query level for that i tried with whereJsonContains
I am not sure about whereJsonContains but following way will work
$result = Table::where(“json_data->$id” ,$reqid)->get();
dd($result);
I need to Get data for an index for a timeframe using curl or using url.
I was able to get the data using below created url
http://localhost:9200/index_name/_search?size=10&q="* AND severity:major|critical"
but I am not sure where to provide the timeframe for example i only want data from last 15minutes.
Can anyone help me with a way it can be done
You can do it like this by adding #timestamp:[now-15m TO now] to your query:
http://localhost:9200/index_name/_search?size=10&q="* AND severity:major|critical AND #timestamp:[now-15m TO now]"
I have a user object with dozens of keys on it. Is it possible to give a query some parameters such that only certain fields on the user come back and I have to fetch the rest?
To limit the keys in the returned result set you can use 'keys' parameter in rest api.
Sample GET request:
https://demodomain/parse/classes/ClassName?keys=key1,key2,key3
For more:
https://docs.parseplatform.org/rest/guide/#query-constraints
When performing a query against BigQuery, it outputs useful info in logs, but the return value is simply the query payload. Is there any way to programmatically get the query metadata in addition to the query result?
Example:
bigquery = Google::Cloud::Bigquery.new(…)
result = bigquery.query(sql)
Debug-level logs will show something like:
#total_bytes_processed=102412,
#total_rows=12915
I'm wondering how that could be accessed programmatically.
Don't know the specifics of Ruby (I don't use that language), but when you submit your query, you'll get back a "job id". Use this id to retrieve the meta information about the job/query using the Job API.
https://cloud.google.com/bigquery/docs/jobs-overview
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/get
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#resource
I want to load the details based on the user location. When I query for the results it is always returning empty array. What to do?
This is my query:
https://api.parse.com/1/classes/TSLocation?where{"location":"{\"nearSphere\":{\"__type\":\"GeoPoint\",\"latitude\":34.944251,\"longitude\":-111.753343}}","limit":10}
I have also added the headers along with the HttpRequest. Can you please guide if anybody knows
Finally I got it..actually my query was wrong.In the above query at location i am passing JsonString instead of JSONObject.
Formatted Query is:
https://api.parse.com/1/classes/TSLocation?where={"location":{"$nearSphere":{"__type":"GeoPoint","longitude":-74.00594130000002,"latitude":40.7127837}}}&limit=10
It is $nearSphere not nearSphere, try this
https://api.parse.com/1/classes/TSLocation?where{"location":"{\"$nearSphere\":{\"__type\":\"GeoPoint\",\"latitude\":34.944251,\"longitude\":-111.753343}}"}&limit=10