User bio
404 bio not found
Member since Nov 9, 2022
Replies:

This is not a trick but a feature that I don't see used very often, but defining a unique index provides you with auto generated methods to get an oref to a row in a table by column value rather than by knowing the %ID of the row.

For example, here's a simple table with two columns:

class DC.Example Extends %Persistent {
    Property Name As %String;
    Property DOB As %Date;
    
    Index NameIDX On Name [Unique];
}

Let's insert a value into this table:

INSERT INTO DC.Example(Name, DOB) VALUES('John',TO_DATE('01 Jan 1986'))

Suppose you know that one of the rows in a table contains the name "John" but you want to get their DOB, you can get the oref by using an auto-generated method called "NameIDXOpen()" like so:

set oref = ##class(DC.Example).NameIDXOpen("John")
write $ZDATE(oref.DOB) //prints out "01/01/86"

For the curious: https://docs.intersystems.com/iris20261/csp/docbook/DocBook.UI.Page.cls…

The open error location feature is specially helpful. I no longer have to count lines while trying to remember which type of comment counts as a line for offset purposes.

I'd argue that Python generators should be in this list too. They are like a genie that can generate a rock sample on the fly without having to store the rocks in a big box.

Certifications & Credly badges:
Ali has no Certifications & Credly badges yet.
Followers:
Following:
Ali has not followed anybody yet.