intersystems-community / ideas-and-innovations

InterSystems Developer Community Ideas and Requests for Innovative Solutions with InterSystems IRIS
MIT License
5 stars 0 forks source link

Add Navigation methods for InterSystems Objects Indexed properties #23

Closed evshvarov closed 4 years ago

evshvarov commented 5 years ago

InterSystems Objects has the feature to get the Id of instance for a property value if the property has Unique Index. e.g.: ClassMethod IndexOpen(val, concurrency, sc As %Status) and ClassMethod IndexExists(val, Output id) As %Boolean

Learn more in this article: https://community.intersystems.com/post/useful-auto-generated-methods

This works only for Unique indexes. It'd be great if we have auto-generated methods for navigation on instances which have same values for the property with the option to get the all the id for the property value.

hermanslagman commented 5 years ago

We'll need navigational methods such as: First(), Next(), Previous() and Last() both on the IdKey and on Indices. So something like:

class(Person).Next(IdKey)

class(Person).Next(KeyValue)

Multi-level indices would then be a little harder I've discussed this many years ago with ISC developers but they were very reluctant to implement this. The argument was to use SQL for this. (I didn't/don't agree)

Gra-ach commented 5 years ago

@hermanslagman What is the point of having First, Next, Previous and Last for IdKey, if it is unique and they all should return the same value? I'm curious now, how one can add methods into the system class like %Persistent or wherever the methods for working with indices are realized?

Vassil2010 commented 4 years ago

see the article on this topic https://community.intersystems.com/post/indexnameopen-and-navigation-methods-non-unique-indexes