Select specific nodes programmatically

Hello. I try to make a selection of some parts on my diagram. I want to select the nodes that the figure is ‘Database’. I make the basic filtering on my nodeDataArray:
const dBs = this.diagram.model.nodeDataArray.filter(node => node.fig === ‘Database’);
But then I’m not able to select all the items in this array. I was trying something like:
dBs.forEach(db => {;
but it selects only the last item of the array

Call Diagram.selectCollection.

Ok but in my case dBs gets the type go.ObjectData[] from the filtering that i make. whats the correct way to filter those nodes. thanks

const nodes = this.diagram.model.nodeDataArray
    .filter(data => data.fig === "Database")
    .map(data => this.diagram.findNodeForData(data));

I Still have this type error and typescript does’t let me to call selectCollection with dBs arg:
“Argument of type ‘(Node | null)[]’ is not assignable to parameter of type ‘Iterable | Part[]’.”
I had to type cast as go.Part[] the argument. Thanks anyway here is my code:

const dBs = this.diagram.model.nodeDataArray.filter(data => data.fig === "Database").map(db => this.diagram.findNodeForData(db));

 ` this.diagram.selectCollection(dBs as go.Part[])`

Also the part .map(this.diagram.findNodeForData); is throwing an error :
core.js:6498 ERROR TypeError: Cannot read properties of undefined (reading ‘gj’)
at t.gj (go.js:724)
at ()
which i solved with my map above.

You hadn’t mentioned TypeScript before. Try my updated code. Notice also that I always refer to model data as “data” and diagram Nodes or Links as "node"s or "link"s, in order to clarify which half of the world the object belongs to.

Οk thanks and I apologies for the confusion