How to apply condition inside column. If column having array data? - database

Suppose I have category table and having name field.
Inside name column I have array data like ["News","Entairntment","Food"].
Here how will I get data which category.name = Food.
Here I can't make where or where_in condition.
Any help.
thanks!!

Related

Sort by field from jsonb column

I'm using npgsql to store data about shipments and part of table is jsonb column storing some details about shipment including details about customer who made shipment.
Table for displaying data about shipments is displaying only Customer Name and if get that record via
CustomerName = shipment.Metadata.RootElement.GetProperty("customer").GetProperty("customerName").ToString(),
Request is that I make this column sortable so I would need to sort by this property while accessing database.
Is it even possible to do it in NpgSql?
You can easily sort by a property inside a JSON document - just specify that property in your OrderBy clause:
_ = await ctx.Shipments
.OrderBy(s => s.Metadata.RootElement.GetProperty("customer").GetProperty("customerName").GetString())
.ToListAsync();
This produces the following:
SELECT s."Id", s."Metadata"
FROM "Shipments" AS s
ORDER BY s."Metadata"#>>'{customer,customerName}'
You should probably be able to make this use an index as well.

Is it possible to nest values based on key column in AppSheet?

I have a table connected to AppSheet that has a column called "Names" there are many values that have the same name with different information. Is there anyway in AppSheet to have the user tap on one name and have all of the values show up that have the same Customer name. Essentially grouping.
I know there is a community on Google Plus for AppSheet but it doesn't seem very active my question has been sitting on the site for weeks. If anyone needs more clarification please ask.
Not very clear what you are trying to achieve, but you can correct me if I'm wrong.
You want in the Inline view of any given Customer, to have a list of referenced values.
You can do this with a SELECT() function. In Data > Columns > + "Virtual column"
In the "App formula" input add your function.
For example: SELECT( myTable[myColumn], [Name] = [_THISROW].[Name])
What this does:
List all values from column named "myColumn" in table "myTable"
where "Name" has the same "Name" as this row,
https://help.appsheet.com/expressions/functions/select
If you want to list not only values but a list of referenced rows from another table, you should use REF_ROWS.
For example REF_ROWS("myOrdersTable", "orderCustomer")
What this does: list all rows from table named "myOrdersTable" where column named "orderCustomer" has the same value as the unique KEY of this row.
REF_ROW virtual columns are generated automatically when you give a "REF" type to any column. In this example if you go to Data > Columns > "myOrdersTable" and change the type of "orderCustomer" to "REF" with "ReferencedTableName" to "myCustumerTable", a virtual column with list of referenced rows will be generated in "myCustumerTable" table after you save.
https://help.appsheet.com/data/references/references-between-tables

How to print all values with same key in one row?

I am new in AngularJS. I wanted to ask how to print all the values with similar key in a row, then another set of values with similar key in another row. For eg. I have to print employees name with similar age in one row etc..Can anybody give me a solution?
It's better to have data as array for ng-repeat.
Now, pre process that data in controller or service to group them based on the criteria ( same age in your case ) and then simply ng-repeat.

Laravel show records as flat array or single record

I have 2 column in my table setting
with the following values
KEY VALUE
company ABC
phone 14344
address Somerset City
I need to display this like a single record or a flatten
array in the view/blade page
something like
{{$sett->company}}
{{$sett->phone}}
or an array with lookup
{{$myarray('company')}}
{{$myarray('phone')}}
The idea is if I add another settings like contact us email address
for my website I don't want to add another column.
I know this is achievable in controller by creating different variable
and executing different query but I'm kind of looking for some options here.
Thanks for the help really appreciated.
You can use $settings->pluck('value', 'key') to get your result. Read more here: https://laravel.com/docs/5.4/collections#method-pluck

ShieldUI Grid - Hide Columns by index?

Is it possible to hide columns by index? The hideColumn() function uses the field NAME:
hideColumn(columnField)
I guess I'll have to create an array of fieldnames and do it that way?
You can take the name of the data field in a certain column, specifying its index like this:
$("#grid .sui-gridheader th.sui-headercell:eq(0)").attr("data-field")
However, you will have to take into account things such as whether it is hidden or not.

Resources