Project all fields except X - amazon-dynamodb

I'm trying to return partial documents with DynamoDB. Instead of listing all the items I want returned using ProjectionExpression, it would be far easier in this case to just filter the single item I don't want returned.
i.e. below, I'd like to return everything except privateItem.
{
"item1" : ...,
"item2" : ...,
"privateItem" : {
...
}
}
Is this possible? I've scoured the docs to no avail.
Thanks.

Based upon the docs it seems that you can't, you can only get either every field or a whitelist of fields (maybe that'll change in future though).
In your case I would imagine the best thing to do is to delete/filter the field you don't want after you've retrieved the document from DynamoDB.

Related

(GuideWire 9 ClaimCenter) Unable to return a single AssignmentSearchType

I have a Range Input that's taking in an array of AssignmentSearchTypes for the valueRange. My task is to conditionally limit the search types based on the user's role. In particular, we want to only allow certain roles to assign jobs directly to another user. I've done this successfully, but when I actually pull up the page in a browser the "User" SearchType is always included, even when it shouldn't be.
I've tried declaring an array that only contains the desired SearchType
return new AssignmentSearchType[] { AssignmentSearchType.TC_GROUP }
but for some reason the TC_USER element still appears first in the rendered drop-down, in addition to TC_GROUP. I've stepped through the project line by line in the debugger, but it hasn't proved useful thus far.
Any ideas, Guidewire folks?

Getting selections from a list object

I have a table inside of appmaker that I've added checkboxes to like so:
I'd like to get a list of the emails from entires that the user checks. At this point I'm not even able to access the status of a single checkbox. This is the current code snippet I tried adding to a button:
console.log(widget.parent.parent.parent.children.Panel1.children.Table3Panel.children.Table3.children.Table3Body.children.Table3Row.children.UserSelectionCheckbox.value);
I get the error:
Cannot read property 'children' of undefined
at Home.Panel1.OuSelectPanel1.Button6.onClick:1:133
I was able to use the autofill to write this entire statement, why can't it find the child object? Is there any way to reference this list directly without going down the tree from the widget or the app root?
For this type of functionality the autofill (intellisense) will not work for you. You need to address the children differently when you try to get a collection of rows from a table. I would suggest code similar to this for your button onClick event:
var rows = widget.root.descendants.Table3Body.children._values;
var emails = [];
for (var i in rows) {
var value = rows[i].children.Checkbox1.value;
if (value) {
emails.push(rows[i].datasource.item.Email);
}
}
console.log(emails);
Again the auto complete code feature simply won't work after you choose the _values, which will return all immediate children of your table body, which is what you want.
based on the 1:133 it seems to be saying that Table3Row has no children. I wonder if using widget.root.descendants.Table3Row might be a different way of doing it address the particular table.

Firestore Update fields in nested objects with dynamic key

I need to update a field in a nested object with a dynamic key.
the path could look like this: level1.level2.DYNAMIC_KEY : updatedValue
The update-method deletes everything else on level1 instead of only updating the field in the nested object. The update() acts more like a set(). What am I doing wrong?
I tried the following already:
I read the documentation https://firebase.google.com/docs/firestore/manage-data/add-data#update-data
but that way it is a) static and b) still deletes the other fields.
Update fields in nested objects
If your document contains nested objects, you can use "dot notation" to reference nested fields within the document when you call update()
This would be static and result in
update({
'level1.level2.STATIC_KEY' : 'updatedValue'
});
Then I found this answer https://stackoverflow.com/a/47296152/5552695
which helped me to make the updatepath dynamic.
The desired solution after this could look like
field[`level1.level2.${DYNAMIC_KEY}`] = updateValue;
update(field);
But still: it'll delete the other fields in this path.
UPDATE:
The Structure of my Doc is as follows:
So inside this structure i want to update only complexArray > 0 > innerObject > age
Writing the above path into the update() method will delete everything else on the complexArray-level.
A simple update on first-level-fields works fine and lets the other first-level-fields untouched.
Is it possible, that firestore functions like update() can only act on the lowest field-level on an document. And as soon as i put complex objects into an document its not possible to select such inner fields?
I know there would be the solution to extract those "complex" objects into separate collections + documents and put these into my current lowest document level. I think this would be a more accurate way to stick to the FireStore principles. But on Application side it is easier to work with complex object than to always dig deeper in firestore collection + document structure.
So my current solution is to send the whole complex object into the update() method even though I just changed only one field on application side.
Have you tried using the { merge: true } option in your request?
db
.collection("myCollection")
.doc("myDoc")
.set(
{
level1: { level2: { myField: "myValue" } }
},
{ merge: true }
)

Firebase: updating issue

I have a database with the following structure:
I need to update the order's amount child value and then add a new child updatedAt which will have the timestamp of this update.
I use an object of which contains the paths that I want to update and then call ref.update(dataToBeUpdated).
The problem is that the children that I didn't update as the timestamp is removed when I call update() .. it acts like I rewrite the order node and not editing some of its children.. any help?
UPDATE :
Here is how the code looks like :
var dataToUpdate = { [orderPath] : { 'amount': newAmount, 'updatedAt': firebase.database.ServerValue.TIMESTAMP } } return ref.update(dataToUpdate)
It's over writing your data, most likely because you aren't providing the full-path. For example if you are only providing ref.child("postID").update(update) you're overwriting everything under that "postID". I can't really provide an exact solution without seeing your data and code. If you update your post I can provide additional details, but for now try this: ref.child("amount").update(newAmount) and ref.child("updatedAt").update(newTimestamp)
The first one should overwrite the old amount and the second one should add the child updatedAt with your timestamp.
Another way would be to download all the existing data for that order update it locally and then re-upload the whole thing.
Take a look at the update documentation

What's the right way to check if collection.find success in Meteor?

The Meteor document said 'find returns a cursor', and can use 'fetch' to return all matching documents, but I didn't find a complete reference of this 'cursor' object.
I want to use this 'cursor' object to check if find sucessfully got some result or got nothing.
Following is what I am doing now:
if (Tags.find({name: tag["tag"]}).fetch().length === 0) {
// Not found, add default documents
}
Not sure if this is right way(best practice) to do this?
The idiom is to use .findOne:
if (!Tags.findOne(...)) {
// nothing found, add default documents
}
This is more efficient than fetch() because it only queries the database for one document.
You can also use <cursor>.count, but beware that in Mongo, count operations are expensive.

Resources