MongoDB compass unable to [Select Type] select specific type - complex-data-types

in Insert Document, e.g if I want to select "Object" type, i am unable to find it, unable to scroll from up/down arrow keys
1 _id : objectId("5ecgftr654gfhfyr7565gfvy5ff") ObjectId
2 Address : " " String

Related

cube.js - mongodb DBref field inside schema dimension section

I am trying to create a filter on DBref id field (mongodb). The SQL query generated is given below
SELECT
`part_r_f_q_dpa`.`partRFQId` `part_r_f_q_dpa__partrfqid`,
`part_r_f_q_dpa`.`noOfApproval` `part_r_f_q_dpa__noofapproval`,
`part_r_f_q_dpa`.`CurrentApproved` `part_r_f_q_dpa__currentapprove`
FROM
makethepart.`directPartApproval` AS `part_r_f_q_dpa`
LEFT JOIN makethepart.`partRFQ` AS `part_r_f_q` ON `part_r_f_q_dpa`.partRFQId = `part_r_f_q`._id
WHERE
(`part_r_f_q`.`creatorBuyer.$id` = ?)
GROUP BY
1,
2,
3
ORDER BY
1 ASC
LIMIT
10000
I am getting an error "Error: Unknown column 'part_r_f_q.creatorBuyer.$id' in 'where clause'".
The code excerpt under dimensions in the schema is as below
creatorbuyer: {
sql: `${CUBE}.\`creatorBuyer.$id\``,
type: string
can someone please let me know how should we handle the dbrefs ids as shown above
$id in Mongo BI is referenced as _id. You should use _id instead of $id.

postgres - make a search by part of a word (node js)

I want to make a search by some part of a word from Postgres database. For example:
I have 3 columns in the table (id,name,last_name).
I want to make a route -->
/get-users-by-name
someone send me response ( for example 'An') and I look which name have the same start (and I get list with next names "Anne,Andrew,Antony" etc).
Can I make this search directly in the db or I should get all table from db and the parse it by forEach function?
Table like :
id : 1 ,name : Andrew , last_name : First
id : 2 ,name : Antony , last_name : Second
id : 3 ,name : Anne , last_name : Third
If I will pass input as An - I will get all list , because all started from 'An'

libreoffice base create a list filtered by another list's value

I have a table of provinces and a table of cities with ProvienceID. In a form, I want to create a list of cities filtered by selected value of provience list.
How can I do that?
I can create both lists but Cities list shows all cities from all provinces but i want to show only cities from the province that I have selected in Provinces list.
I have another table "Users" with "CityID" and "ProvinceID" that my form edits it and I need to save selected values of Province and City Lists in it, not only show it in the form.
Create two example tables named "Provinces" and "Cities".
ProvinceID Name
~~~~~~~~~~ ~~~~
0 South
1 North
2 Large Midwest
3 Southeast
4 West
CityID Name ProvinceID
~~~~~~ ~~~~ ~~~~~~~~~~
0 Big City 2
1 Very Big City 2
2 Rural Village 1
3 Mountain Heights 0
4 Coastal Plains 4
5 Metropolis 2
Create a query called "ProvinceNames":
SELECT "Name" AS "Province"
FROM "Provinces"
ORDER BY "Province" ASC
Create a query called "Province of City":
SELECT "Provinces"."Name" AS "Province", "Cities"."Name" AS "City"
FROM "Cities", "Provinces" WHERE "Cities"."ProvinceID" = "Provinces"."ProvinceID"
ORDER BY "Province" ASC, "City" ASC
In the form, create a table control based on the query "ProvinceNames".
Using the Form Navigator (or the Form Wizard), create a subform for query "Province of City".
Right-click on subform and choose Properties. Under Data tab:
Link master fields "Province"
Link slave fields "Province"
Create a table control for the subform as well. Now, the cities shown in the subform control depend on the province selected in the main form control.
EDIT:
Here is an example using a filter table to store the current value of the list box. Create two more tables named "Users" and "FilterCriteria".
UserID Name ProvinceID CityID
~~~~~~ ~~~~~~~ ~~~~~~~~~~ ~~~~~~
0 Person1 1 2
1 Person2 2 0
RecordID ProvinceID CityID
~~~~~~~~ ~~~~~~~~~~ ~~~~~~
the only 0 0
We'll also need two Basic macros which can be stored in the document or in My Macros. Go to Tools -> Macros -> Organize Macros -> LibreOffice Basic.
Sub ReadProvince (oEvent as Object)
forms = ThisComponent.getDrawPage().getForms()
mainForm = forms.getByName("MainForm")
cityForm = forms.getByName("CityForm")
listboxProvince = mainForm.getByName("listboxProvince")
listboxCity = cityForm.getByName("listboxCity")
selectedItemID = listboxProvince.SelectedValue
If IsEmpty(selectedItemID) Then
selectedItemID = 0
End If
conn = mainForm.ActiveConnection
stmt = conn.createStatement()
strSQL = "UPDATE ""FilterCriteria"" SET ""ProvinceID"" = " & selectedItemID & _
"WHERE ""RecordID"" = 'the only'"
stmt.executeUpdate(strSQL)
listboxCity.refresh()
lCityCol = mainForm.findColumn("CityID")
currentCityID = mainForm.getInt(lCityCol)
cityForm.updateInt(cityForm.findColumn("CityID"), currentCityID)
listboxCity.refresh()
End Sub
Sub CityChanged (oEvent as Object)
listboxCity = oEvent.Source.Model
cityForm = listboxCity.getParent()
mainForm = cityForm.getParent().getByName("MainForm")
lCityCol = mainForm.findColumn("CityID")
selectedItemID = listboxCity.SelectedValue
If IsEmpty(selectedItemID) Then
selectedItemID = 0
End If
mainForm.updateInt(lCityCol, selectedItemID)
End Sub
Now we need to set up the form like this. In this example, I used two top-level forms instead of a subform. ProvinceID and CityID text boxes are not required but may be helpful in case something goes wrong.
To start creating this form, use the form wizard to create a new form and add all fields from the Users table.
Now, in the Form Navigator, create a form called "CityForm". Content type is SQL command, and Content is:
SELECT "RecordID", "ProvinceID", "CityID" FROM "FilterCriteria"
WHERE "RecordID" = 'the only'
Next, create the "listboxProvince" list box under MainForm. Data Field is "ProvinceID", and List content is the following Sql.
SELECT "Name", "ProvinceID" FROM "Provinces" ORDER BY "Name" ASC
Finally, create the "listboxCity" list box under CityForm. Data Field is "CityID", and List content is the following Sql.
SELECT "Name", "CityID" FROM "Cities" WHERE "ProvinceID" = (
SELECT "ProvinceID" FROM "FilterCriteria"
WHERE "RecordID" = 'the only')
Macros are linked under the Events tab of each control.
Assign "After record change" of the MainForm to ReadProvince().
Assign "Changed" of listboxProvince to ReadProvince().
Assign "Changed" of listboxCity control to CityChanged().
The result allows us to select the Province to filter the list of Cities. Provinces and Cities that are selected are saved in the Users table.
There is another approach which may be better that I have not had time to explore. Instead of the "FilterCriteria" table, apply a filter to the Cities list. The relevant code in ReadProvince() would look something like this.
cityForm.Filter = "ProvinceID=" & selectedItemID
cityForm.ApplyFilter = True
cityForm.reload()
cityForm.absolute(0)
Whatever approach is taken, a complete solution requires complex macro programming. To make it easier, you may decide to use a simpler solution that is not as powerful. For more information, there is a tutorial at https://forum.openoffice.org/en/forum/viewtopic.php?t=46470.
EDIT 2
A solution that requires fewer queries is at https://ask.libreoffice.org/en/question/143186/how-to-use-user-selected-value-from-combobox1-in-combobox2-select-statement/?answer=143231#post-id-143231. The second list box is based on a list of values instead of an SQL query.

Finding documents in mongodb collection where a field is equal to given integer value

I would like to find all documents where the field property_id is equal to -549. I tried:
db.getCollection('CollectionName').find({'property_id' : -549 })
This returns no records with a message: "Fetched 0 record(s)."
But I am seeing the document right there where the field property_id is -549.
I am not sure what I am doing wrong. The type of field is int32.
Check if there is a space in the field name 'property_id':
Try
db.getCollection('CollectionName').find({'\uFEFFproperty_id' : -549 })

SphinxQL match this field OR this field

My database contains a table with a field called "tag".
I'd like to get all rows where "tag" field matches "white tiger" OR "brown lion".
I tried the following syntax but not working:
SELECT * FROM mytable WHERE MATCH('#tag white tiger|brown lion');
Thankf for your help!