Getting user documents
There are three ways to get a list of documents the user belongs to.
The main, recommended way to fetch documents is with the User.getDocumentPaginator
function.
You can also get all a user's documents with the User.getAllDocuments
function.
Lastly, you can get a specific document with the User.getDocument
API.
#
getDocumentPaginatorThe User.getDocumentPaginator
function is used to fetch the user's documents in a paginated manner. This is the recommended way to fetch documents.
getDocumentPaginator(options): Paginator
options
(PaginateParams) options to pass to the paginatorlimit
(number) how many entities to fetch with each request. This property is required.orderBy
('updatedAt' | 'createdAt') how the entities should be ordered when querying. Defaults to 'updatedAt', meaning documents that were most recently updated will be fetched firstorderDirection
('ASC' | 'DESC') which direction the entities should be ordered when querying. Defaults to 'DESC' meaning newer documents are fetched first.before
(number - timestamp in MS) Sets the query to only fetch items that were updated/created at before this date. Used to fetch older documents. Defaults to the current time.
Returns a Paginator
instance.
Example
#
getPublicDocumentPaginatorThis API can be used to fetch all public documents in a paginated manner. Note that it will also return documents the user is already a member of.
getPublicDocumentPaginator(options): Paginator
options
(PaginateParams) options to pass to the paginatorlimit
(number) how many entities to fetch with each request. This property is required.orderBy
('updatedAt' | 'createdAt') how the entities should be ordered when querying. Defaults to 'updatedAt', meaning documents that were most recently updated will be fetched firstorderDirection
('ASC' | 'DESC') which direction the entities should be ordered when querying. Defaults to 'DESC' meaning newer documents are fetched first.before
(number - timestamp in MS) Sets the query to only fetch items that were updated/created at before this date. Used to fetch older documents. Defaults to the current time.
Returns a Paginator
instance.
Example
#
getAllDocumentsgetAllDocuments(): Promise<Document[]>
The getAllDocuments
returns an array of all the users documents. This API should not be used in large scale applications, as it does not scale up with the number of documents a user belongs to.
Resolves to an array of Documents.
Example
#
getDocumentThe getDocument
API gets a single Document by its ID.
getDocument(id): Promise<Document>
id
(string) The ID of the document to fetch
Example