Model without db-table

Silverstripe Version:4.4

Possible to have a model as subclass from DataObject without db-table

E.g. if you are using googlesitemaps, all “registered” Models have to be inherited from DataObject
And some more use cases

// tried this with no luck
public function requireTable(){

dev/build states errors - it tries to execute some sql queries.

Kind of the whole point of a DataObject is that it represents a model which contains Data that needs to be stored in the database. So I think you will be fighting an uphill battle to prevent a DataObject from having a table - it’s just part of its DNA.

Assuming you are using Wilr\GoogleSitemaps, any objects that you want to generate a URL for in the sitemap would need to be present as a record in the database because the module loops over those to generate URLs for each object.

However, you can also register arbitrary URLs with that module, so maybe that’s a better option for you?

You can use subclasses of ArrayData to have some objects without DB connection that can be rendered in templates. However, this doesn’t come with relations to other objects, so you’d have to create this on your own.

I think maybe you want ViewableData.

DataObject is a subclass of ViewableData that also has database content. If you want a DataObject without the db stuff, that’s a ViewableData object.