Datastore filter array field - datastore

I have an array field on the Datastore.
How I can filter it? Will this work?
query := datastore.NewQuery("Task").Filter("student_ids =",id)

Related

Query Datasource field data type and using it in scriban to fetch details of datasource item

How to use 'Query Datasource' field data type so that I can point to another datasource item from my scriban item itself and able to retrive its (pointed datasource item) field values?
Any suggestion here?

How to create a field with a list of choices but store the index?

I'm making a Microsoft Access table where one of the fields is a list of pre-made options. When I make a SQL query on that table it returns the values of the list as strings containing the spelled out choice. I would like to assign numerical values to each element of the list so a SQL query returns a number instead. How do I do this? I know it's possible because I have an access file with such a list but I'm unable to recreate it.
An easy way to do this is to have your combo box use a query of the table as a Rowsource. This query would have the table unique ID in the first field and the field you wish to return as the second field. Then change the setting on the combo box for "Column Count" to 2. If you want to show both fields change the "Column Widths" value to 1"; 1". If you want to show only one field, change the value of one you do not want to see to 0. Now we you refer to this list in an SQL queries, it will use the ID field but show the user the string field.

Filter Dynamo DB rows

I want to filter all dynamo db rows where 2 columns have same value
table = client.Table('XXX')
response = table.query(
KeyConditionExpression=Key('column1').eq(KeyConditionExpression=Key('column2'))
)
this is wrong as we can't pass KeyConditionExpression inside eq statement. I don't want to scan through all the rows and filter the rows.
Scanned through multipole resources and answers but every resources talks about the multiple column checking with some value not multiple condition involving columns
Is there anyway we can achieve this?
Yes, this is possible.
If you want query over all records you need to use scan, if you want to query only records with one specific partition key you can use query.
For both you can use a FilterExpression, which will filter the records after retrieving them from the database, but before returning them to the user (so beware, using a scan with this will read all your records).
A scan from the CLI could look like this:
aws dynamodb scan \
--table-name your-table \
--filter-expression "#i = #j" \
--expression-attribute-names '{"#i": "column1", "#j": "column2"}'
Create a Global Secondary Index with a partition key of 'Column1Value#Column2Value'
Then it's simply a matter of querying the GSI.

How to fetch string from a JSON array stored in Amazon Redshift column?

I have a database stored in Amazon Redshift and an array is stored in table column in JSON format.
How to fetch a string from array?
Using json_extract_path_text you can retrieve values from a column
In Redshift database I have JSON in one column
This query performs join and to get seperate column results.
SELECT json_extract_path_text(O._doc,'domain') AS Domain,
json_extract_path_text(P._doc,'email') AS Email
FROM intelligense_mongo.organisations AS O
INNER JOIN intelligense_mongo.people AS P
ON json_extract_path_text(O._doc,'_id') =
json_extract_path_text(P._doc,'organisation_id')
Where
json_extract_path_text(O._doc,'tools_name') = '%"WordPress"%'
Use the JSON_EXTRACT_PATH_TEXT Function:
select json_extract_path_text('{"f2":{"f3":1},"f4":{"f5":99,"f6":"star"}}','f4', 'f6');
json_extract_path_text
----------------------
star

APEX dynamic tabular form field types

We are populating a subregion of a page with an Iframe (call to another page) with data for a questionnaire.
We have PAGE ITEM variables (:P37_... populated by query) that contain table values for P37_QUESTION_DESCRIPTION and P37_RESPONSE_TYPE.
The sub page used in the region (:P28_...) assigns report attributes for each column... where We populated the question text in the P28_QUESTION_DESC and a Y/N Select List defined list of values in the P28_RESPONSE_DESC_DISPLAY column. This works fine.
Now, the P37_RESPONSE_TYPE can more than just this Y/N Select List. It could be TEXTAREA, PICKLIST, DATE...
How can we define the :P28_RESPONSE_DESC_DISPLAY column dynamically to be any number of user input field types (based on the value in :P37_REPSONSE_TYPE?)
This was solved by using a non-tabular form report generated by query using apex.item functions. But is has left me with another problem. Here's the query:
select
apex_item.hidden(31,CASE_QUEST_DTL_ID) CASE_QUEST_DTL_ID,
apex_item.hidden(32,CASE_MGMT_BASE_ID) CASE_MGMT_BASE_ID,
apex_item.display_and_save(33,to_number(question_seq_no)) QUESTION_SEQ_NO,
apex_item.display_and_save(34,question_desc) QUESTION_DESC,
case when response_type = 'PICKLIST-YESNO' then apex_item.select_list_from_lov(35,response_desc,'YES_NO_SELECTLIST',NULL,'NO')
when response_type = 'TEXTFIELD' then apex_item.text(35,response_desc)
when response_type = 'TEXTAREA' then apex_item.textarea(35,response_desc,5,40)
when response_type = 'DATEPICKER' then APEX_ITEM.DATE_POPUP2(35,to_date(response_desc,'dd-mon-yyyy'),'dd-mon-yyyy')
end RESPONSE_DESC
from V_CASE_QUEST_LINK
where question_set_code like 'COB_Q%'
and case_mgmt_base_id = :P37_CASE_MGMT_BASE_ID
My problem is now grouping the questions by question_set_code. Because GROUP BY is evaluated after the select, it cannot simply be tacked on to the end of the query. I'm not sure that using a nested select will work here because of the apex.item calls. Anyone have a suggestion on how I can group these questions by the column?