Skip to main content

Resolvers

Resolvers are functions that read/write data from your database based on parameters that we pass in. They are the main link between our server and your database!

There are two types of resolvers, Query and Mutation.

Query resolvers are used to read data from your database. They will be passed in parameters, and the function must return an entity that matches our parameters. For example, if you provide a user query resolver, and we call that resolver with {id: 1}, you would return the user whose userId is 1.

Mutation resolvers are used to write data to your database. We provide the data you need to write, and you can write it however you wish. This means that you can use any database you wish (even an existing one!). For example, if you provide a createUser resolver, and we called it with { name: 'Joe', id: '12345' }, you would write that user to your users table.

info

If you are using the default database, then you can skip this step! More details here.

warning

The examples below use a fictional ORM to make queries to the database. You can use any method you want to make database queries, as long as your resolver function returns the correct data.

Query resolvers#

Query resolvers are passed in via the Query property on the resolvers object.

import CollabServer from "@pdftron/collab-server";
const server = new CollabServer({
resolvers: {
Query: {
...yourResolvers,
},
},
});

Most query resolvers come with a set of filters that you must apply to each query.

user#

user(id): Promise<User>

  • id (string) the id of the user to fetch

Used to get a user entity by its ID.

Must return a promise that resolves to a user, or null if a user is not found.

Example

const server = new CollabServer({
resolvers: {
Query: {
user: async (id) => {
// get a reference to our fictional ORM
const db = getDatabaseConnection();
const user = await db
.select('id, user_name, email, type, created_at, updated_at')
.from('users')
.where('id', '=', id)
.get();
return user;
},
},
},
});

userWithEmail#

userWithEmail(email): Promise<User>

  • email (string) the email of the user we need to fetch

Used to get a user entity by their email. This is used for invites.

Must return a promise that resolves to a user, or null if not found.

Example

const server = new CollabServer({
resolvers: {
Query: {
userWithEmail: async (email) => {
// get a reference to our fictional ORM
const db = getDatabaseConnection();
const user = await db
.select('id, user_name, email, type, created_at, updated_at')
.from('users')
.where('email', '=', email)
.get();
return user;
},
},
},
});

annotations#

info

Please read this spec carefully and make sure to follow all the guidelines provided!

annotation(query): Promise<Annotations[]>

  • query (object) an object containing data and filters to query with
    • ids (string[]) a list of annotation IDs to fetch. If this is not provided, fetch all annotations that match the rest of the criteria.
    • documentId (string) if provided, only fetch annotations belonging to this document
    • pageNumbers (number[]) if provided, only fetch annotations that match one of the provided page numbers
    • inReplyTo (string) if provided, only fetch annotations whose inReplyTo field matches this ID
    • filters (Filters) an object containing filters to apply to the query.

Used to get a list of annotations.

Must return a promise that resolves to an array of annotations.

Example

const server = new CollabServer({
resolvers: {
Query: {
annotation: async (query) => {
const {
ids,
documentId,
pageNumbers,
inReplyTo,
filters = {}
} = query;
// get a reference to our fictional ORM
const db = getDatabaseConnection();
let query = db
.select('*')
.from('annotations');
if(ids) {
query = query.where('id', 'IN', ids)
}
if(pageNumbers) {
query = query.where('page_number', 'IN', pageNumbers)
}
if(documentId) {
query = query.where('document_id', '=', documentId)
}
if(inReplyTo) {
query = query.where('in_reply_to', '=', inReplyTo)
}
if(filters.createdBefore) {
query = query.where('created_at', '<', filters.createdBefore)
}
if(filters.createdAfter) {
query = query.where('created_at', '>', filters.createdAfter)
}
if(filters.updatedBefore) {
query = query.where('updated_at', '<', filters.updatedBefore)
}
if(filters.updatedAfter) {
query = query.where('updated_at', '>', filters.updatedAfter)
}
if(filters.orderBy) {
query = query.order(
filters.orderBy === 'updatedAt' ? 'updated_at' : 'created_at',
filters.orderDirection
)
}
if (filters.limit) {
query = query.limit(filters.limit)
}
const annots = await query.get()
return annots;
},
},
},
});

documents#

info

Please read this spec carefully and make sure to follow all the guidelines provided!

documents(query): Promise<Document[]>

  • query (object) an object containing data and filters to query with
    • ids (string[]) a list of document IDs to fetch. If this is not provided, fetch all documents that match the rest of the criteria.
    • userId (string) if provided, only fetch documents that this user belongs to (requires a query to document members - see the example below)
    • filters (Filters) an object containing filters to apply to the query.

Used to get a list of documents.

Must return a promise that resolves to an array of documents.

Example

const server = new CollabServer({
resolvers: {
Query: {
documents: async (query) => {
const {
ids,
userId
filters = {}
} = query;
// get a reference to our fictional ORM
const db = getDatabaseConnection();
let query = db
.select('*')
.from('documents');
if(ids) {
query = query.where('id', 'IN', ids)
}
if(userId) {
query = query.where(
'id',
'IN',
`
(SELECT document_id FROM document_members WHERE user_id = '${userId}')
`)
}
if(filters.createdBefore) {
query = query.where('created_at', '<', filters.createdBefore)
}
if(filters.createdAfter) {
query = query.where('created_at', '>', filters.createdAfter)
}
if(filters.updatedBefore) {
query = query.where('updated_at', '<', filters.updatedBefore)
}
if(filters.updatedAfter) {
query = query.where('updated_at', '>', filters.updatedAfter)
}
if(filters.orderBy) {
query = query.order(
filters.orderBy === 'updatedAt' ? 'updated_at' : 'created_at',
filters.orderDirection
)
}
if (filters.limit) {
query = query.limit(filters.limit)
}
const docs = await query.get()
return docs;
},
},
},
});

annotationMembers#

info

Please read this spec carefully and make sure to follow all the guidelines provided!

annotationMembers(query): Promise<AnnotationMember[]>

  • query (object) an object containing data and filters to query with
    • ids (string[]) a list of document IDs to fetch. If this is not provided, fetch all members that match the rest of the criteria.
    • annotationId (string) if provided, only fetch members that belong to this annotation
    • userId (string) if provided, only fetch memberships that belong to this user
    • filters (Filters) an object containing filters to apply to the query.

Used to get a user's membership to an annotation.

Must return a promise that resolves to a list of annotation members.

Example

const server = new CollabServer({
resolvers: {
Query: {
annotationMembers: async (query) => {
const {
ids,
annotationId,
userId,
filters = {}
} = query;
// get a reference to our fictional ORM
const db = getDatabaseConnection();
let query = db
.select('*')
.from('annotation_members');
if(ids) {
query = query.where('id', 'IN', ids)
}
if(userId) {
query = query.where('user_id', '=', userId);
}
if(annotationId) {
query = query.where('annotation_id', '=', annotationId);
}
if(filters.createdBefore) {
query = query.where('created_at', '<', filters.createdBefore)
}
if(filters.createdAfter) {
query = query.where('created_at', '>', filters.createdAfter)
}
if(filters.updatedBefore) {
query = query.where('updated_at', '<', filters.updatedBefore)
}
if(filters.updatedAfter) {
query = query.where('updated_at', '>', filters.updatedAfter)
}
if(filters.orderBy) {
query = query.order(
filters.orderBy === 'updatedAt' ? 'updated_at' : 'created_at',
filters.orderDirection
)
}
if (filters.limit) {
query = query.limit(filters.limit)
}
const members = await query.get()
return members;
},
},
},
});

documentMembers#

info

Please read this spec carefully and make sure to follow all the guidelines provided!

documentMembers(query): Promise<DocumentMember[]>

  • query (object) an object containing data and filters to query with
    • ids (string[]) a list of document IDs to fetch. If this is not provided, fetch all members that match the rest of the criteria.
    • documentId (string) if provided, only fetch members that belong to this document
    • userId (string) if provided, only fetch memberships that belong to this user
    • filters (Filters) an object containing filters to apply to the query.

Used to get a user's membership to a document.

Must return a promise that resolves to a an array of document member.

Example

const server = new CollabServer({
resolvers: {
Query: {
documentMembers: async (query) => {
const {
ids,
documentId,
userId,
filters = {}
} = query;
// get a reference to our fictional ORM
const db = getDatabaseConnection();
let query = db
.select('*')
.from('document_members');
if(ids) {
query = query.where('id', 'IN', ids)
}
if(userId) {
query = query.where('user_id', '=', userId);
}
if(documentId) {
query = query.where('document_id', '=', documentId);
}
if(filters.createdBefore) {
query = query.where('created_at', '<', filters.createdBefore)
}
if(filters.createdAfter) {
query = query.where('created_at', '>', filters.createdAfter)
}
if(filters.updatedBefore) {
query = query.where('updated_at', '<', filters.updatedBefore)
}
if(filters.updatedAfter) {
query = query.where('updated_at', '>', filters.updatedAfter)
}
if(filters.orderBy) {
query = query.order(
filters.orderBy === 'updatedAt' ? 'updated_at' : 'created_at',
filters.orderDirection
)
}
if (filters.limit) {
query = query.limit(filters.limit)
}
const members = await query.get()
return members;
},
},
},
});

mentions#

info

Please read this spec carefully and make sure to follow all the guidelines provided!

mentions(query): Promise<Mentions[]>

  • query (object) an object containing data and filters to query with
  • ids (string[]) a list of mention IDs to fetch. If this is not provided, fetch all mentions that match the rest of the criteria.
  • annotationId (string) if provided, only fetch mentions that belong to this annotation
  • userId (string) if provided, only fetch mentions that belong to this user
  • documentId (string) if provided, fetch all mentions that belong to this document
  • filters (Filters) an object containing filters to apply to the query.

Used to get a user's mention to an annotation.

Must return a promise that resolves to a list of mentions.

Example

const server = new CollabServer({
resolvers: {
Query: {
mentions: async (query) => {
const {
ids,
annotationId,
userId,
filters = {}
} = query;
// get a reference to our fictional ORM
const db = getDatabaseConnection();
let query = db
.select('*')
.from('mentions');
if(ids) {
query = query.where('id', 'IN', ids)
}
if(userId) {
query = query.where('user_id', '=', userId);
}
if(annotationId) {
query = query.where('annotation_id', '=', annotationId);
}
if(filters.createdBefore) {
query = query.where('created_at', '<', filters.createdBefore)
}
if(filters.createdAfter) {
query = query.where('created_at', '>', filters.createdAfter)
}
if(filters.updatedBefore) {
query = query.where('updated_at', '<', filters.updatedBefore)
}
if(filters.updatedAfter) {
query = query.where('updated_at', '>', filters.updatedAfter)
}
if(filters.orderBy) {
query = query.order(
filters.orderBy === 'updatedAt' ? 'updated_at' : 'created_at',
filters.orderDirection
)
}
if (filters.limit) {
query = query.limit(filters.limit)
}
const mentions = await query.get()
return mentions;
},
},
},
});

annotationCount#

annotationCount(query): Promise<number>

  • query (object)
    • documentId (string) query the number of annotations for this document
    • since (number - timestamp in ms) query the number of annotations that were created after this time

This is a very important query that is used to calculate the number of unread messages for a user. It needs to return the number of annotations belonging to the specified document that were created AFTER the since parameter.

Example

const server = new CollabServer({
resolvers: {
Query: {
annotationCount: async ({ documentId, since }) => {
// get a reference to our fictional ORM
const db = getDatabaseConnection();
const query = db.select('COUNT(DISTINCT id)')
.from('annotations')
.where('document_id', '=', documentId)
.where('created_at', '>', since)
const count = await query.get();
return count;
},
},
},
});

annotationMemberCount#

annotationMemberCount(query): Promise<number>

  • query (object)
    • documentId (string) query the number of annotation members for this document
    • userId (string) query memberships for this user
    • since (number - timestamp in ms) query the number of annotation members where "annotation_created_at" is greater than this timestamp

This is another important query that we use to calculate unread count for a document. It needs to return the number of annotation members where annotation_created_at is greater than the since parameter.

In other words, this query returns the number of annotation members whose corresponding annotation was created after since.

Example

const server = new CollabServer({
resolvers: {
Query: {
annotationMemberCount: async ({ userId, documentId, since }) => {
// get a reference to our fictional ORM
const db = getDatabaseConnection();
const query = db.select('COUNT(DISTINCT id)')
.from('annotation_members')
.where('document_id', '=', documentId)
.where('user_id', '=', userId)
.where('annotation_created_at', '>', since)
const count = await query.get();
return count;
},
},
},
});

Mutation resolvers#

Mutation resolvers are passed in via the Mutation property on the resolvers object.

import CollabServer from "@pdftron/collab-server";
const server = new CollabServer({
resolvers: {
Mutation: {
...yourResolvers,
},
},
});

addUser#

addUser(user): Promise<User>

  • user (User) The user entity to write to the database

Used to create new users in the database. This is mainly for creating anonymous users when a person without an account is invited.

Must resolve with the written user entity.

Example

const server = new CollabServer({
resolvers: {
Mutation: {
addUser: async (user) => {
// get a reference to our fictional ORM
const db = getDatabaseConnection();
const newUser = await db
.insert('users')
.values({
id: user.id,
type: user.type,
email: user.email,
user_name: user.userName,
created_at: user.createdAt,
updated_at: user.updatedAt
});
return newUser;
},
},
},
});

addAnnotation#

addAnnotation(annotation): Promise<Annotation>

Used to save an annotation to the database.

Must resolve with the saved annotation object.

Example

const server = new CollabServer({
resolvers: {
Mutation: {
addAnnotation: async (annotation) => {
// get a reference to our fictional ORM
const db = getDatabaseConnection();
const newAnnot = await db
.insert('annotations')
.values({
id: annotation.id,
xfdf: annotation.xfdf,
document_id: annotation.documentId,
page_number: annotation.pageNumber,
created_at: annotation.createdAt,
updated_at: annotation.updatedAt,
in_reply_to: annotation.inReplyTo
});
return newAnnot;
},
},
},
});

editAnnotation#

editAnnotation(id, editAnnotInput): Promise<Annotation>

  • id (string) the ID of the annotation to edit
  • editAnnotInput (object) an object containing the fields to edit. Can contain the following (both optional)
    • xfdf (string) The annotation's new XFDF (optional)
    • pageNumber (number) The annotation's new pageNumber (optional)
    • updatedAt (number) the timestamp of when the entity was updated at

Used to edit an annotation. This is called when an existing annotation is moved, changed, etc.

Must resolve to the new annotation entity.

Example

const server = new CollabServer({
resolvers: {
Mutation: {
editAnnotation: async (id, editAnnotInput) => {
// get a reference to our fictional ORM
const db = getDatabaseConnection();
const editedAnnot = await db
.edit('annotations')
.values({
xfdf: editAnnotInput.xfdf,
page_number: editAnnotInput.pageNumber,
updated_at: editAnnotInput.updatedAt,
})
.where('id', '=', id)
return editedAnnot;
},
},
},
});

deleteAnnotation#

deleteAnnotation(id): Promise<{ successful: boolean }>

  • id (string) the id of the annotation to delete

Used to delete annotations from the database.

Must resolve to an object with a successful boolean, indicating if the operation was successful.

Example

const server = new CollabServer({
resolvers: {
Mutation: {
deleteAnnotation: async (id) => {
// get a reference to our fictional ORM
const db = getDatabaseConnection();
await db.delete('annotations').where('id', '=', id)
return { successful: true };
},
},
},
});

addDocument#

addDocument(document): Promise<Document>

  • document (Document) the document to write to the database

Used to add a document to the database.

Must resolve with the new document object

Example

const server = new CollabServer({
resolvers: {
Mutation: {
addDocument: async (doc) => {
// get a reference to our fictional ORM
const db = getDatabaseConnection();
const newDoc = await db
.insert('documents')
.values({
id: doc.id,
author_id: doc.authorId,
is_public: doc.isPublic,
name: doc.name,
created_at: doc.createdAt,
updated_at: doc.updatedAt,
});
return newDoc;
},
},
},
});

editDocument#

editDocument(id, editDocInput): Promise<Document>

  • id (string) the id of the document to edit
  • editDocInput (object) the fields to edit on the document (all properties are optional)
    • name (string) the document's new name
    • isPublic (boolean) whether or not the document is now public
    • updatedAt (number) the timestamp of when the entity was updated at

Used to edit a document.

Must resolve with the updated document entity.

Example

const server = new CollabServer({
resolvers: {
Mutation: {
editDocument: async (id, editDocInput) => {
// get a reference to our fictional ORM
const db = getDatabaseConnection();
const editedDoc = await db
.edit('documents')
.values({
name: editDocInput.name,
is_public: editDocInput.isPublic,
updated_at: editDocInput.updatedAt,
})
.where('id', '=', id)
return editedDoc;
},
},
},
});

deleteDocument#

deleteDocument(id): Promise<{ successful: boolean }>

  • id (string) the id of the document to delete

Used to delete a document from the DB.

Must resolve with an object with a successful property indicating if the operation was successful.

Example

const server = new CollabServer({
resolvers: {
Mutation: {
deleteDocument: async (id) => {
// get a reference to our fictional ORM
const db = getDatabaseConnection();
await db.delete('documents').where('id', '=', id)
return { successful: true };
},
},
},
});

addDocumentMember#

addDocumentMember(member): Promise<DocumentMember>

Used to write a document membership to the database.

Must resolve with the created document member entity.

Example

const server = new CollabServer({
resolvers: {
Mutation: {
addDocumentMember: async (member) => {
// get a reference to our fictional ORM
const db = getDatabaseConnection();
const newMember = await db
.insert('document_members')
.values({
id: member.id,
user_id: member.userId,
document_id: member.documentId,
created_at: member.createdAt,
updated_at: member.updatedAt,
last_read: member.lastRead
});
return newMember;
},
},
},
});

editDocumentMember#

editDocumentMember(id, editMemberInput): Promise<DocumentMember>

  • id (string) the id of the document member to edit
  • editMemberInput (object) the properties to edit on the member
    • lastRead (number) the timestamp of when the person read the document
    • updatedAt (number) the timestamp of when the entity was updated at

Used to edit the membership of a document member.

Must resolve to the updated document member

Example

const server = new CollabServer({
resolvers: {
Mutation: {
editDocumentMember: async (id, editMemberInput) => {
// get a reference to our fictional ORM
const db = getDatabaseConnection();
const editedMember = await db
.edit('document_members')
.values({
last_read: editMemberInput.lastRead,
updated_at: editMemberInput.updatedAt,
})
.where('id', '=', id)
return editedMember;
},
},
},
});

deleteDocumentMember#

deleteDocumentMember(id): Promise<{ successful: boolean }>

  • id (string) the id of the document member to delete

Used to delete a document member from the database.

Must resolve to an object with a successful property indicating if the operation was successful or not.

Example

const server = new CollabServer({
resolvers: {
Mutation: {
deleteDocumentMember: async (id) => {
// get a reference to our fictional ORM
const db = getDatabaseConnection();
await db.delete('document_members').where('id', '=', id)
return { successful: true };
},
},
},
});

addAnnotationMember#

addAnnotationMember(member): Promise<AnnotationMember>

Used to write an annotation member to the database.

Must resolve with the new annotation member.

Example

const server = new CollabServer({
resolvers: {
Mutation: {
addAnnotationMember: async (member) => {
// get a reference to our fictional ORM
const db = getDatabaseConnection();
const newMember = await db
.insert('annotation_members')
.values({
id: member.id,
user_id: member.userId,
document_id: member.documentId,
annotation_id: member.annotationId,
created_at: member.createdAt,
updated_at: member.updatedAt,
annotation_created_at: member.annotationCreatedAt
});
return newMember;
},
},
},
});

editAnnotationMember#

editAnnotationMember(id, editMemberInput): Promise<AnnotationMember>

  • id (string) the id of the annotation member to edit
  • editMemberInput (object) the properties to update on the annotation member (all are optional)
    • lastRead (number) the timestamp of when the last time the person read the annotation
    • updatedAt (number) the timestamp of when the entity was updated at

Used to update a user's membership to an annotation.

Must resolve with the updated annotation member.

Example

const server = new CollabServer({
resolvers: {
Mutation: {
editAnnotationMember: async (id, editMemberInput) => {
// get a reference to our fictional ORM
const db = getDatabaseConnection();
const editedMember = await db
.edit('annotation_members')
.values({
last_read: editMemberInput.lastRead,
updated_at: editMemberInput.updatedAt,
})
.where('id', '=', id)
return editedMember;
},
},
},
});

deleteAnnotationMember#

deleteAnnotationMember(id): Promise<{ successful: boolean }>

  • id (string) the id of the member to delete

Used to delete an annotation member.

Must resolve with an object containing a successful property indicating if the operation was successful or not.

Example

const server = new CollabServer({
resolvers: {
Mutation: {
deleteAnnotationMember: async (id) => {
// get a reference to our fictional ORM
const db = getDatabaseConnection();
await db.delete('annotation_members').where('id', '=', id)
return { successful: true };
},
},
},
});

addMention#

addMention(mention): Promise<mention>

  • mention (Mention) the mention to write

Used to write a mention to the database.

Must resolve with the new mention.

Example

const server = new CollabServer({
resolvers: {
Mutation: {
addMention: async (mention) => {
// get a reference to our fictional ORM
const db = getDatabaseConnection();
const newMention = await db
.insert('mentions')
.values({
id: mention.id,
user_id: mention.userId,
document_id: mention.documentId,
annotation_id: mention.annotationId,
created_at: mention.createdAt,
updated_at: mention.updatedAt,
});
return newMention;
},
},
},
});

editMention#

editMention(id, editMentionInput): Promise<Mention>

  • id (string) the id of the mentions to edit
  • editMentionInput (object) the properties to update on the mention (all are optional)
    • readBeforeMention (boolean) whether the annotation that the mention belongs to had been read before the mention was created.
    • updatedAt (number) the timestamp of when the entity was updated at

Used to update a mention in an annotation.

Must resolve with the updated mention.

Example

const server = new CollabServer({
resolvers: {
Mutation: {
editMention: async (id, editMentionInput) => {
// get a reference to our fictional ORM
const db = getDatabaseConnection();
const editedMention = await db
.edit('mentions')
.values({
readBeforeMention: editMentionInput.readBeforeMention
})
.where('id', '=', id)
return editedMention;
},
},
},
});

deleteMention#

deleteMention(id): Promise<{ successful: boolean }>

  • id (string) the id of the mention to delete

Used to delete a mention.

Must resolve with an object containing a successful property indicating if the operation was successful or not.

Example

const server = new CollabServer({
resolvers: {
Mutation: {
deleteMention: async (id) => {
// get a reference to our fictional ORM
const db = getDatabaseConnection();
await db.delete('mentions').where('id', '=', id)
return { successful: true };
},
},
},
});

Resolver entities#

User entity#

A user entity is an object with the following shape. Properties with a ? are optional (but recommended).

{
id: string;
type: 'STANDARD' | 'ANONYMOUS';
email?: string;
userName?: string;
createdAt: number (UTC timestamp in MS);
updatedAt: number (UTC timestamp in MS);
}

Document entity#

A document entity is an object with the following shape. Properties with a ? are optional (but recommended).

{
id: string;
authorId: string;
createdAt: number (UTC timestamp in MS);
updatedAt: number (UTC timestamp in MS);
isPublic?: boolean;
name?: string;
}

Annotation entity#

An annotation entity is an object with the following shape. Properties with a ? are optional (but recommended).

{
id: string;
xfdf: string;
authorId: string;
documentId: string;
pageNumber: number;
createdAt: number (UTC timestamp in MS);
updatedAt: number (UTC timestamp in MS);
inReplyTo?: string;
}

DocumentMember entity#

{
id: string;
userId: string;
documentId: string;
lastRead: number (UTC timestamp in MS);
createdAt: number (UTC timestamp in MS);
updatedAt: number (UTC timestamp in MS);
}

AnnotationMember entity#

An annotation member entity is an object with the following shape. Properties with a ? are optional (but recommended).

An annotation member represents a user's 'membership' to an annotation. It is also used to track if a user has read an annotation or not.

{
id: string;
userId: string;
documentId: string;
annotationId: string;
lastRead: number (UTC timestamp in MS);
createdAt: number (UTC timestamp in MS);
updatedAt: number (UTC timestamp in MS);
annotationCreatedAt: number (UTC timestamp in MS);
}

Mention entity#

A mention entity is an object with the following shape. Properties with a ? are optional (but recommended).

A mention represents a mentioned user in an annotation.

{
id: string;
userId: string;
documentId: string;
annotationId: string;
readBeforeMention?: boolean;
createdAt: number (UTC timestamp in MS);
updatedAt: number (UTC timestamp in MS);
}

Filters#

Most Query resolvers come with a filter object, containing 7 properties that should be used when making your query.

  • filters (object) an object containing filters to apply to the query
    • createdBefore (number - timestamp in MS) If provided, only fetch entities created before this date
    • createdAfter (number - timestamp in MS) If provided, only fetch entities created after this date
    • updatedBefore (number - timestamp in MS) If provided, only fetch entities updated before this date
    • updatedAfter (number - timestamp in MS) If provided, only fetch entities updated after this date
    • orderBy ('updatedAt' | 'createdAt') if provided, order/sort your query by updatedAt or createdAt
    • orderDirection ('ASC' | 'DESC') if provided, order your query in the provided direction
    • limit (number) if provided, limit your query to this amount

It is important that these filters are used properly, as they are what allows the application to scale.

note

Since these filters are the same across all queries, it is recommended to create a utility function to apply the filters to your queries!