Skip to main content

types_types.contextvalue

easybase-react / types/types / ContextValue

Interface: ContextValue

types/types.ContextValue

Table of contents

Properties

Methods

Properties

e

โ€ข e: NewExpression

Expressions and operations builder for .db(), used to create complex conditions, aggregators, and clauses. https://easybase.github.io/EasyQB/docs/operations.html

Defined in: src/types/types.tsx:290

Methods

Frame

โ–ธ Frame(): Record<string, any>[]

DEPRECATED: Use db instead - https://easybase.github.io/EasyQB/

deprecated Use db instead - https://easybase.github.io/EasyQB/

Returns: Record<string, any>[]

Array of records corresponding to the current frame. Call sync() to push changes that you have made to this array.

Defined in: src/types/types.tsx:226

โ–ธ Frame(index: number): Record<string, any>

DEPRECATED: Use db instead - https://easybase.github.io/EasyQB/

deprecated Use db instead - https://easybase.github.io/EasyQB/

Parameters:

NameType
indexnumber

Returns: Record<string, any>

Single record corresponding to that object within the current frame. Call sync() to push changes that you have made to this object.

Defined in: src/types/types.tsx:233


Query

โ–ธ Query(options: QueryOptions): Promise<Record<string, any>[]>

async View a query by name. This returns an isolated array that has no effect on your frame or frame configuration. sync() and Frame() have no relationship with a Query(). An edited Query cannot be synced with your database, use Frame() for realtime database array features.

Parameters:

NameTypeDescription
optionsQueryOptionsQueryOptions

Returns: Promise<Record<string, any>[]>

Isolated array of records in the same form as Frame(). Editing this array has no effect and cannot be synced with your database. Use Frame() for realtime database features.

Defined in: src/types/types.tsx:273


addRecord

โ–ธ addRecord(options: AddRecordOptions): Promise<StatusResponse>

DEPRECATED: Use db().insert() instead - https://easybase.github.io/EasyQB/docs/insert_queries.html

deprecated Use db().insert() instead - https://easybase.github.io/EasyQB/docs/insert_queries.html

async

Parameters:

NameTypeDescription
optionsAddRecordOptionsAddRecordOptions

Returns: Promise<StatusResponse>

Defined in: src/types/types.tsx:149


configureFrame

โ–ธ configureFrame(options: ConfigureFrameOptions): StatusResponse

DEPRECATED: Use db instead - https://easybase.github.io/EasyQB/

deprecated Use db instead - https://easybase.github.io/EasyQB/

Parameters:

NameTypeDescription
optionsConfigureFrameOptionsConfigureFrameOptions

Returns: StatusResponse

StatusResponse

Defined in: src/types/types.tsx:141


currentConfiguration

โ–ธ currentConfiguration(): FrameConfiguration

View your frames current configuration

Returns: FrameConfiguration

Object contains the offset and length of your current frame.

Defined in: src/types/types.tsx:264


db

โ–ธ db(tableName?: string, userAssociatedRecordsOnly?: boolean): SQW

Instantiate EasyQB instance for dynamic CRUD query building: https://easybase.github.io/EasyQB/

Parameters:

NameType
tableName?string
userAssociatedRecordsOnly?boolean

Returns: SQW

EasyQB object for dynamic querying: https://easybase.github.io/EasyQB/

Defined in: src/types/types.tsx:280


dbEventListener

โ–ธ dbEventListener(callback: (status?: DB_STATUS, queryType?: string, executeCount?: EXECUTE_COUNT, tableName?: null | string, returned?: any) => void): function

Subscribe to db events, invoked by calling .all or .one: https://easybase.github.io/EasyQB/

Parameters:

NameType
callback(status?: DB_STATUS, queryType?: string, executeCount?: EXECUTE_COUNT, tableName?: null | string, returned?: any) => void

Returns: () => void

Calling this function unsubscribes your callback function from events.

Defined in: src/types/types.tsx:286


deleteRecord

โ–ธ deleteRecord(options: DeleteRecordOptions): Promise<StatusResponse>

DEPRECATED: Use db().delete() instead - https://easybase.github.io/EasyQB/docs/delete_queries.html

deprecated Use db().delete() instead - https://easybase.github.io/EasyQB/docs/delete_queries.html

async

Parameters:

NameType
optionsDeleteRecordOptions

Returns: Promise<StatusResponse>

Defined in: src/types/types.tsx:157


forgotPassword

โ–ธ forgotPassword(username: string, emailTemplate?: EmailTemplate): Promise<StatusResponse>

async Trigger an email to the given username with a verification code to reset the user's password. This verification code is used in the forgotPasswordConfirm function, along with a new password. The username must be the user's email address.

Parameters:

NameTypeDescription
usernamestringA username which must also be a valid email address
emailTemplate?EmailTemplateOptional details for the formatting & content of the verification email

Returns: Promise<StatusResponse>

A StatusResponse corresponding to the successful sending of a verification code email

Defined in: src/types/types.tsx:321


forgotPasswordConfirm

โ–ธ forgotPasswordConfirm(code: string, username: string, newPassword: string): Promise<StatusResponse>

async Confirm the resetting of an unauthenticated users password. This function is invoked after forgotPassword is used to trigger an email containing a verification code to the given username [which must also be an email]. The user's randomly generated verification code from their email is passed in the first parameter.

Parameters:

NameTypeDescription
codestringVerification code found in the email sent from the forgotPassword function
usernamestringThe same username (email) used in the forgotPassword function
newPasswordstringThe new password for the corresponding verified user

Returns: Promise<StatusResponse>

A StatusResponse corresponding to the successful setting of a new password

Defined in: src/types/types.tsx:332


fullTableSize

โ–ธ fullTableSize(): Promise<number>

Gets the number of records in your table.

async

Returns: Promise<number>

The the number of records in your table.

Defined in: src/types/types.tsx:239

โ–ธ fullTableSize(tableName: string): Promise<number>

Gets the number of records in your table.

async

Parameters:

NameType
tableNamestring

Returns: Promise<number>

The the number of records in your table.

Defined in: src/types/types.tsx:246


getUserAttributes

โ–ธ getUserAttributes(): Promise<Record<string, string>>

Retrieve the currently signed in users attribute object.

async

Returns: Promise<Record<string, string>>

Promise<Record<string, string>>

Defined in: src/types/types.tsx:92


isUserSignedIn

โ–ธ isUserSignedIn(): boolean

Check if a user is currently signed in.

Returns: boolean

Is a user signed in.

Defined in: src/types/types.tsx:82


onSignIn

โ–ธ onSignIn(callback: () => void): void

Pass a callback function to run when a user signs in. This callback function will run after either successfully signing in with the signIn() function OR after a user is automatically signed in via valid tokens saved to the browser from a previous instance. This is best placed with useEffect(() => {}, []);

Parameters:

NameTypeDescription
callback() => voidcallback function to run on sign in event

Returns: void

Defined in: src/types/types.tsx:77


resetUserPassword

โ–ธ resetUserPassword(currentPassword: string, newPassword: string): Promise<StatusResponse>

Reset the currently signed-in user's password to a new string.

async

Parameters:

NameTypeDescription
currentPasswordstringSigned-in user's current password
newPasswordstringNew password for user's account

Returns: Promise<StatusResponse>

Defined in: src/types/types.tsx:108


setFile

โ–ธ setFile(recordKey: string, columnName: string, file: File | FileFromURI, tableName?: string): Promise<StatusResponse>

Upload a file to your backend and attach it to a specific record. columnName must reference a column of type 'file'.

async

Parameters:

NameTypeDescription
recordKeystringThe '_key' of the record to attach this image to. Can be retrieved like: db().return("_key").where({ title: "The Lion King" }).one()
columnNamestringThe name of the column that is of type file to attach.
fileFile | FileFromURIEither an HTML File element or a FileFromURI object for React Native instances. For React Native, use libraries such as react-native-image-picker and react-native-document-picker.
tableName?string-

Returns: Promise<StatusResponse>

Defined in: src/types/types.tsx:220


setImage

โ–ธ setImage(recordKey: string, columnName: string, image: File | FileFromURI, tableName?: string): Promise<StatusResponse>

Upload an image to your backend and attach it to a specific record. columnName must reference a column of type 'image'. The file must have a valid image extension (png, jpg, heic, etc).

async

Parameters:

NameTypeDescription
recordKeystringThe '_key' of the record to attach this image to. Can be retrieved like: db().return("_key").where({ title: "The Lion King" }).one()
columnNamestringThe name of the column that is of type image to attach.
imageFile | FileFromURIEither an HTML File element or a FileFromURI object for React Native instances. For React Native, use libraries such as react-native-image-picker and react-native-document-picker. The file name must have a valid image file extension.
tableName?string-

Returns: Promise<StatusResponse>

Defined in: src/types/types.tsx:199


setUserAttribute

โ–ธ setUserAttribute(key: string, value: string): Promise<StatusResponse>

Set a single attribute of the currently signed in user. Can also be updated visually in the Easybase 'Users' tab.

async

Parameters:

NameTypeDescription
keystringObject key. Can be a new key or existing key.
valuestringattribute value.

Returns: Promise<StatusResponse>

Defined in: src/types/types.tsx:100


setVideo

โ–ธ setVideo(recordKey: string, columnName: string, video: File | FileFromURI, tableName?: string): Promise<StatusResponse>

Upload a video to your backend and attach it to a specific record. columnName must reference a column of type 'video'. The file must have a valid video extension (webm, mp4, mov, etc).

async

Parameters:

NameTypeDescription
recordKeystringThe '_key' of the record to attach this image to. Can be retrieved like: db().return("_key").where({ title: "The Lion King" }).one()
columnNamestringThe name of the column that is of type video to attach.
videoFile | FileFromURIEither an HTML File element or a FileFromURI object for React Native instances. For React Native, use libraries such as react-native-image-picker and react-native-document-picker. The file name must have a valid video file extension.
tableName?string-

Returns: Promise<StatusResponse>

Defined in: src/types/types.tsx:210


signIn

โ–ธ signIn(userID: string, password: string): Promise<StatusResponse>

Sign in a user that already exists for a project. This will save authentication tokens to a user's browser so that they will be automatically authenticated when they return to the application. These authentication tokens will become invalid when a user signs out or after 24 hours.

async

Parameters:

NameTypeDescription
userIDstringunique identifier for new user. Usually an email or phone number.
passwordstringuser password.

Returns: Promise<StatusResponse>

Defined in: src/types/types.tsx:118


signOut

โ–ธ signOut(): void

Sign out the current user and invalidate their cached tokens.

Returns: void

Defined in: src/types/types.tsx:86


signUp

โ–ธ signUp(newUserID: string, password: string, userAttributes?: Record<string, string>): Promise<StatusResponse>

Create a new user for your project. You must still call signIn() after signing up.

async

Parameters:

NameTypeDescription
newUserIDstringunique identifier for new user. Usually an email or phone number.
passwordstringuser password. Must be at least 8 characters long.
userAttributes?Record<string, string>Optional object to store user attributes. Can also be edited visually in the Easybase 'Users' tab.

Returns: Promise<StatusResponse>

Defined in: src/types/types.tsx:127


sync

โ–ธ sync(): Promise<StatusResponse>

DEPRECATED: Use db instead - https://easybase.github.io/EasyQB/

deprecated Use db instead - https://easybase.github.io/EasyQB/

async

Returns: Promise<StatusResponse>

Defined in: src/types/types.tsx:164


tableTypes

โ–ธ tableTypes(): Promise<Record<string, any>>

Retrieve an object detailing the columns in your table mapped to their corresponding type.

async

Returns: Promise<Record<string, any>>

Object detailing the columns in your table mapped to their corresponding type.

Defined in: src/types/types.tsx:252

โ–ธ tableTypes(tableName: string): Promise<Record<string, any>>

Retrieve an object detailing the columns in your table mapped to their corresponding type.

async

Parameters:

NameType
tableNamestring

Returns: Promise<Record<string, any>>

Object detailing the columns in your table mapped to their corresponding type.

Defined in: src/types/types.tsx:259


updateRecordFile

โ–ธ updateRecordFile(options: UpdateRecordAttachmentOptions): Promise<StatusResponse>

DEPRECATED: Use the setFile function instead.

deprecated Use the setFile function instead.

async

Parameters:

NameTypeDescription
optionsUpdateRecordAttachmentOptionsUpdateRecordAttachmentOptions

Returns: Promise<StatusResponse>

Defined in: src/types/types.tsx:188


updateRecordImage

โ–ธ updateRecordImage(options: UpdateRecordAttachmentOptions): Promise<StatusResponse>

DEPRECATED: Use the setImage function instead.

deprecated Use the setImage function instead.

async

Parameters:

NameTypeDescription
optionsUpdateRecordAttachmentOptionsUpdateRecordAttachmentOptions

Returns: Promise<StatusResponse>

Defined in: src/types/types.tsx:172


updateRecordVideo

โ–ธ updateRecordVideo(options: UpdateRecordAttachmentOptions): Promise<StatusResponse>

DEPRECATED: Use the setVideo function instead.

deprecated Use the setVideo function instead.

async

Parameters:

NameTypeDescription
optionsUpdateRecordAttachmentOptionsUpdateRecordAttachmentOptions

Returns: Promise<StatusResponse>

Defined in: src/types/types.tsx:180


useFrameEffect

โ–ธ useFrameEffect(effect: EffectCallback): void

DEPRECATED: Use db instead - https://easybase.github.io/EasyQB/

This hook runs when the Frame changes. This can be triggered by calling sync().

Parameters:

NameTypeDescription
effectEffectCallbackCallback function that executes when Frame changes.

Returns: void

Defined in: src/types/types.tsx:134


useReturn

โ–ธ useReturn<T>(dbInstance: () => SQW, deps?: DependencyList): UseReturnValue<T>

Custom stateful hook to an instance of db().return. Other local changes will automatically re-fetch the query as detailed in the passed-in db.


const { frame } = useReturn(() => db('MYTABLE').return().where(e.gt('rating', ratingState)).limit(10), [ratingState])

const onButtonClick = (_key) => {
db('MYTABLE').delete().where({ _key }).all();
}

// Stays fresh after call to `.delete()`
return (<div>{ frame.map(ele => <Card {...ele} />) }</div>)

Type parameters:

NameDefault
TRecord<string, any>

Parameters:

NameTypeDescription
dbInstance() => SQWFunction returning an instance of db().return without having called .all or .one
deps?DependencyListIf present, instance will be reloaded if the values in the list change.

Returns: UseReturnValue<T>

Object with the required values to statefully access an array that is subscribed to local executions to the corresponding db instance.

Defined in: src/types/types.tsx:312


userID

โ–ธ userID(): undefined | string

Retrieve the currently signed-in user's ID.

Returns: undefined | string

The currently signed-in user's ID (username), otherwise undefined.

Defined in: src/types/types.tsx:337