Trisk
Trisk

Reputation: 593

OrientDB: Filter select on super class

Using the OrientDB console there is a command to show all records with a class that extends a base class.

browse class Asset

This returns all records that have a class (Object1, Object2) that extends Asset.

I'm looking for a SQL command that can do the same.

Currently this query does not return the same set of records.

SELECT * V where @class = 'Asset'

Upvotes: 4

Views: 788

Answers (3)

Charles Hebdough
Charles Hebdough

Reputation: 226

If you are looking for all superclasses of a given class, this worked for me:

select superClasses from (select expand(classes) from metadata:schema) where name = "myClassName"

Upvotes: 0

Luigi Dell'Aquila
Luigi Dell'Aquila

Reputation: 2814

you can also use instanceof operator,

eg.

 select from V where @this instanceof 'Asset'

This makes sense especially in v. 2.1 where you have multiple inheritance, in cases when you want to retrieve documents that are subclasses of two different parent classes

Upvotes: 5

AlexB
AlexB

Reputation: 3548

To retrieve all the records from Object1 and Object2, a simple select query from the superclass name should work :

select from Asset

Upvotes: 3

Related Questions