Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sdk-client): getCollection method for content (#28635)
## Proposed Changes * Add `Content` Class to handle Content API Methods and expose it as a method of the Dotcms Client * Add `GetCollection` Class to handle the building of a query for collections and expose it as a method of `Content` Class ## Usage example for standalone `getCollection` This an example of a query with all possible methods it supports (could not be a real use case and it should be used from the `client.content`). ```typescript const requestOptions: Omit<RequestInit, 'body' | 'method'> = { cache: 'no-cache' // To simulate a valid request }; const serverUrl = 'http://localhost:8080'; const contentType = 'forceSensitive'; const client = new GetCollection(requestOptions, serverUrl, contentType); const response = await client .language(13) // Language Id .render(true) // To retrieve the content with the render .sortBy([ // Sort by multiple fields { field: 'name', order: 'asc' }, { field: 'midichlorians', order: 'desc' } ]) .depth(2) // Depth of the content for relationships .limit(20) // Limit of content per page .page(3) // Page to fetch .query( ( qb // Lucene query to append to the main query for more complex queries ) => qb .field('kyberCrystal') .equals('red') .and() .equals('blue') .field('master') .equals('Yoda') .or() .equals('Obi-Wan') ) .draft(true) // To retrieve the draft content .variant('legends-forceSensitive') // Variant of the content .rawQuery('+modDate:2024-05-28 +conhost:MyCoolSite') // Raw query to append to the main query .fetch(); // Fetch the content ```
- Loading branch information