[IMPLEMENTED] Filter on content id => startswith

Hi,

I’m trying to query a content collection on the id with a startwith filter :

GET : https://cloud.squidex.io/api/content/blah-blah/genericpage?$top=10&$skip=0&$filter=startswith(id, ‘418eb854’)

Returns : {
“message”: “Query $filter clause not valid.”,
“details”: [
“Could not find a property named ‘id’ on type ‘Squidex.genericpage’.”
],
“statusCode”: 400
}

The use case is to use a part of the id to get a document, the id fragment is the document identifiers in our Urls.

We could use the complete id but that makes Urls very long (ang ugly).

Am I doing something wrong ? Is this even possible ?

Regards,

Julien

The ID hast just not been added to the query system yet. I can do that for you.

Well, thiat would be great !

Does this mean that the other properties are not accessible yet ? That would be nice to be able to query on them also !

Thanks for the support, which is GREAT !

Julien

What do you mean with other properties?

The properties of the base entity such as created, createdby, lastmodified, everything « « « « above » Data.

They are there: https://github.com/Squidex/squidex/blob/master/src/Squidex.Domain.Apps.Entities/Contents/Edm/EdmModelBuilder.cs

You mean they are already filterable from the c# client and Id was the exception ?

Yes, exactly. I have not seen a use case for the ID :wink:

Wonderful. Thanks for the info.

Last question, I was wondering why the media model in returns a collection by default ? Most the time I need a unique item, for exemple Image for an article and I get a enumerable. Not a big problem (I do a firstordefault()) but I was wondering about the rational here.

So far every field has a single representation and the assets field must support multiple assets of course.

We could make another field that supports a single asset only, but I am not sure if it is worth it.

What is your expectation?

Well I must think about it but I expected a simple reference for the media, a singleton. If I needed a collection of media in my schema I would nest an entity with a single media field (which would nicely inherit form the new orderable feature (thanks by the way)). But that’s entierely debatable.

The “problem” was that the nested fields have been added much later than the assets :wink:

I see. For convenience you could maybe implement two media fields, unique and collection, maybe Media and Medias, but media is already a plural :wink:

I added the ID field to the query system.

Great !

Works : https://cloud.squidex.io/api/content/blah/genericpage?$top=1&$skip=0&$filter=id eq ‘6491c6d2-d3da-4b50-a545-48516b31804f’

Fail: https://cloud.squidex.io/api/content/blah/genericpage?$top=1&$skip=0&$filter=startswith(id, ‘6491c6d2’)

Is my startswith(id, ‘6491c6d2’) filter ok on the Id (Guid) ?

The problem was a general bug with the startswith operator. It must be translated to regex and was translated to $6491c6d2 instead of ^6491c6d2

I have deployed a fix.

Your support is outstanding.

Than you very much for the nice words :slight_smile:

1 Like