Hierarchy

Methods

  • BaseFilesPath returns the storage dir path used by the record.

    Returns string

  • CleanCopy returns a copy of the current record model populated only with its LATEST data state and everything else reset to the defaults.

    Returns models.Record

  • Email returns the "email" auth record data value.

    Returns string

  • Verified returns the "emailVisibility" auth record data value.

    Returns boolean

  • ExpandedAll retrieves a slice of relation Records from the already loaded expand data of the current model.

    If the requested expand relation is single, this method normalizes the return result and will wrap the single model as a slice.

    Returns nil slice if there is no such expand relation loaded.

    Parameters

    • relField: string

    Returns models.Record[]

  • ExpandedOne retrieves a single relation Record from the already loaded expand data of the current model.

    If the requested expand relation is multiple, this method returns only first available Record from the expanded relation.

    Returns nil if there is no such expand relation loaded.

    Parameters

    • relField: string

    Returns models.Record

  • FindFileFieldByFile returns the first file type field for which any of the record's data contains the provided filename.

    Parameters

    • filename: string

    Returns schema.SchemaField

  • Get returns a normalized single record model data value for "key".

    Parameters

    • key: string

    Returns any

  • GetBool returns the data value for "key" as a bool.

    Parameters

    • key: string

    Returns boolean

  • GetFloat returns the data value for "key" as a float64.

    Parameters

    • key: string

    Returns number

  • GetId returns the model id.

    Returns string

  • GetInt returns the data value for "key" as an int.

    Parameters

    • key: string

    Returns number

  • GetString returns the data value for "key" as a string.

    Parameters

    • key: string

    Returns string

  • GetStringSlice returns the data value for "key" as a slice of unique strings.

    Parameters

    • key: string

    Returns string[]

  • GetTime returns the data value for "key" as a [time.Time] instance.

    Parameters

    • key: string

    Returns Time

  • HasId returns whether the model has a nonzero id.

    Returns boolean

  • IgnoreEmailVisibility toggles the flag to ignore the auth record email visibility check.

    Parameters

    • state: boolean

    Returns void

  • IsNew indicates what type of db query (insert or update) should be used with the model instance.

    Returns boolean

  • Load bulk loads the provided data into the current Record model.

    Parameters

    Returns void

  • MarkAsNew marks the model as "new" (aka. enforces m.IsNew() to be true).

    Returns void

  • MarkAsNotNew marks the model as "not new" (aka. enforces m.IsNew() to be false)

    Returns void

  • MarshalJSON implements the [json.Marshaler] interface.

    Only the data exported by PublicExport() will be serialized.

    Returns string | number[]

  • MergeExpand merges recursively the provided expand data into the current model's expand (if any).

    Note that if an expanded prop with the same key is a slice (old or new expand) then both old and new records will be merged into a new slice (aka. a :merge: [b,c] => [a,b,c]). Otherwise the "old" expanded record will be replace with the "new" one (aka. a :merge: aNew => aNew).

    Parameters

    Returns void

  • OriginalCopy returns a copy of the current record model populated with its ORIGINAL data state (aka. the initially loaded) and everything else reset to the defaults.

    Returns models.Record

  • PasswordHash returns the "passwordHash" auth record data value.

    Returns string

  • PostScan implements the [dbx.PostScanner] interface.

    It is executed right after the model was populated with the db row values.

    Returns void

  • PublicExport exports only the record fields that are safe to be public.

    For auth records, to force the export of the email field you need to set m.IgnoreEmailVisibility(true).

    Returns _TygojaDict

  • RefreshCreated updates the model Created field with the current datetime.

    Returns void

  • RefreshId generates and sets a new model id.

    The generated id is a cryptographically random 15 characters length string.

    Returns void

  • RefreshTokenKey generates and sets new random auth record "tokenKey".

    Returns an error if the record is not from an auth collection.

    Returns void

  • RefreshUpdated updates the model Updated field with the current datetime.

    Returns void

  • ReplaceModifers returns a new map with applied modifier values based on the current record and the specified data.

    The resolved modifier keys will be removed.

    Multiple modifiers will be applied one after another, while reusing the previous base key value result (eg. 1; -5; +2 => -2).

    Example usage:

      newData := record.ReplaceModifers(data)
    // record: {"field": 10}
    // data: {"field+": 5}
    // newData: {"field": 15}

    Parameters

    Returns _TygojaDict

  • Set sets the provided key-value data pair for the current Record model.

    If the record collection has field with name matching the provided "key", the value will be further normalized according to the field rules.

    Parameters

    • key: string
    • value: any

    Returns void

  • SetEmail sets the "email" auth record data value.

    This method doesn't check whether the provided value is a valid email.

    Returns an error if the record is not from an auth collection.

    Parameters

    • email: string

    Returns void

  • SetEmailVisibility sets the "emailVisibility" auth record data value.

    Returns an error if the record is not from an auth collection.

    Parameters

    • visible: boolean

    Returns void

  • SetExpand shallow copies the provided data to the current Record model's expand.

    Parameters

    Returns void

  • SetId sets the model id to the provided string value.

    Parameters

    • id: string

    Returns void

  • SetLastLoginAlertSentAt sets an "lastLoginAlertSentAt" auth record data value.

    Returns an error if the record is not from an auth collection.

    Parameters

    Returns void

  • SetLastResetSentAt sets the "lastResentSentAt" auth record data value.

    Returns an error if the record is not from an auth collection.

    Parameters

    Returns void

  • SetLastVerificationSentAt sets an "lastVerificationSentAt" auth record data value.

    Returns an error if the record is not from an auth collection.

    Parameters

    Returns void

  • SetPassword sets cryptographically secure string to the auth record "password" field. This method also resets the "lastResetSentAt" and the "tokenKey" fields.

    Returns an error if the record is not from an auth collection or an empty password is provided.

    Parameters

    • password: string

    Returns void

  • SetTokenKey sets the "tokenKey" auth record data value.

    Returns an error if the record is not from an auth collection.

    Parameters

    • key: string

    Returns void

  • SetUsername sets the "username" auth record data value.

    This method doesn't check whether the provided value is a valid username.

    Returns an error if the record is not from an auth collection.

    Parameters

    • username: string

    Returns void

  • SetVerified sets the "verified" auth record data value.

    Returns an error if the record is not from an auth collection.

    Parameters

    • verified: boolean

    Returns void

  • TableName returns the table name associated to the current Record model.

    Returns string

  • TokenKey returns the "tokenKey" auth record data value.

    Returns string

  • UnknownData returns a shallow copy ONLY of the unknown record fields data, aka. fields that are neither one of the base and special system ones, nor defined by the collection schema.

    Returns _TygojaDict

  • UnmarshalJSON implements the [json.Unmarshaler] interface.

    Parameters

    • data: string | number[]

    Returns void

  • Retrieves the "key" json field value and unmarshals it into "result".

    Example

     result := struct {
    FirstName string `json:"first_name"`
    }{}
    err := m.UnmarshalJSONField("my_field_name", &result)

    Parameters

    • key: string
    • result: any

    Returns void

  • Username returns the "username" auth record data value.

    Returns string

  • ValidatePassword validates a plain password against the auth record password.

    Returns false if the password is incorrect or record is not from an auth collection.

    Parameters

    • password: string

    Returns boolean

  • Verified returns the "verified" auth record data value.

    Returns boolean

  • WithUnknownData toggles the export/serialization of unknown data fields (false by default).

    Parameters

    • state: boolean

    Returns void

Properties

created: types.DateTime
id: string
updated: types.DateTime

Generated using TypeDoc