RethinkDB update and replace-without in one line - rethinkdb

Can anyone think if an elegant way to do update and replace in one line?
I want to use the r.row.without to remove fields and update at the same query.
Something like:
r.db('db').table('table').get('item_id')
.update({ field_a:'value_a'})
.replace(r.row.without(r.args(['field_b'])))`
simply chaining would be nice but this won't work (update returns a change result).

You can also write .update({field_a: 'value_a', field_b: r.literal()}) to change one field and remove another field at the same time.

r.db('db').table('table').get('item_id')
.replace(
r.row.merge(
function(doc){
return {field_a: 'newval'}
}
).without('field_b')
)
Should do the trick

Related

Cypress: How do I get the text of the selected option in a select drop-down list?

I want to be able to get the text of the selected option and not the value. I would use the value but Angular is changing it and putting the value in a ng-reflect-ng-value attribute.
<option _ngcontent-c1="" value="5: 1" ng-reflect-ng-value="1">Miscellaenous</option>
This will work, but I want to check that it equals "Miscellaenous"
cy.get('#id-9999').find('.categoryList').should('have.value','Miscellaenous');
This worked for me:
cy.get('#id-9999').find('.categoryList').find(':selected').contains('Miscellaenous')
This is how it should be done:
cy.get('#id-9999').find('option:selected').should('have.text', 'Miscellaenous');
Among other things, it checks for the exact match and not for a substring (like in your solution).
We've found that chaining find() off get() sometimes breaks our tests, so we use this other way:
cy.get("#my-select-element option:selected")
.should("have.value", 3);
as opposed to:
cy.get("#my-select-element")
.find("selected")
.should("have.value", 3);
When using Cypress I found that :selected did not work, however :checked did work. So to modify one of the other answers here, this works (at least for me):
cy.get("#my-select-element option:checked")
.should("have.value", 3);

How to show more than 10 results in eXide (eXist-db)?

I wonder how to make eXide to return more than 10 results. No matter how I query the database, it is not possible to get more. Is there some special rule in $EXIST_HOME or so?
I use eXist-db 3.0.RC1.
One way is to wrap your query in an element.
<results>{... your query here ...}</results>
Wrapping results is the way to go, but if you wish, you can edit /db/apps/eXide/resources/scripts/eXide.min.js, changing "10" in "q=n+10-1" to some other number.

Use condition in powerpivot (DAX)

My problem is that I can't get the IF condition to work in powerpivot (using DAX).
According to manual the syntax is:
IF(logical_test>,, value_if_false) where I can omitt the "value if false" if i want.
I have a lot of columns and I try to make a new one based on condition from another column.
What I tried is =IF([TimeTypeCode]="400", [WorkingHours]) and that doesn't work. What I want my condition to do is that if [TimeType] is equal to 400, then i want to put the value from [WorkingHours] in my new column. How can i do this?
from what I see here the problem is the ="400", the "" you used tell dax thats a string type and you are trying to use it as a numeric value.
Try using
IF([TimeTypeCode]=400, [WorkingHours])
instead,
Cheers!

LINQ - OR two SqlMethods.Like clauses

I need to OR two SqlMethods.Like statements in LINQ, and I'm not sure how to accomplish it (or if it's the right way to go about it).
I've got vendor ID and vendor name fields, but I've only got a generic vendor search that allows a user to search for a vendor based on their name or ID. I also allow wildcards in the search, so I need to find vendors whose ID or name is like the user's input.
I want to do something like below, but obviously it's not correct. (EDIT: It does work as written.)
results = results.Where(p => SqlMethods.Like(p.VendorId, inputVendor.Replace("*", "%") ||
SqlMethods.Like(p.VendorName, inputVendor.Replace("*", "%"));
Background: I add where statements depending on the search parameters entered by the user, hence the results = results.Where part.
Any help would be appreciated!
It's not clear to me why this is "obviously" not correct. Presumably it's not working, otherwise you wouldn't have posted, but it's not obvious how it's not working.
I would suggest performing the replacement before the query, like this:
string vendorPattern = inputVendor.Replace("*", "%");
But then I'd expect this to work:
results = results.Where(p => SqlMethods.Like(p.VendorId, vendorPattern) ||
SqlMethods.Like(p.VendorName, vendorPattern));
Of course you're limited to where wildcards can appear in a SQL LIKE query, but that's a separate problem. (I'm not sure of the behaviour offhand if it's not at the start or end.)
If that doesn't help, please update the question with what happens when you try this.

How can I remove columns from a QTreeView (using QDirModel)?

I have a QDirModel attached to a QTreeView and I only want to see the paths, not size, type and date modified.
Is there a way to remove these columns?
QTreeView::setColumnHidden(int column, bool hide) should do the trick.
One can also use hideColumn(). Something like:
for i in range(1, self.my_tree_view.header().length()):
self.my_tree_view.hideColumn(i)

Resources