How to use the @nozbe/watermelondb/decorators.field function in @nozbe/watermelondb

To help you get started, we’ve selected a few @nozbe/watermelondb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github RocketChat / Rocket.Chat.ReactNative / app / lib / database / models / Subscription.js View on Github external
@field('alert') alert

	@field('unread') unread

	@field('user_mentions') userMentions

	@field('ro') ro

	@date('last_open') lastOpen

	@field('description') description

	@field('announcement') announcement

	@field('topic') topic

	@field('blocked') blocked

	@field('blocker') blocker

	@field('react_when_read_only') reactWhenReadOnly

	@field('archived') archived

	@field('join_code_required') joinCodeRequired

	@field('notifications') notifications

	@field('broadcast') broadcast

	// // muted: { type: 'list', objectType: 'usersMuted' },
github RocketChat / Rocket.Chat.ReactNative / app / lib / database / models / Subscription.js View on Github external
@field('announcement') announcement

	@field('topic') topic

	@field('blocked') blocked

	@field('blocker') blocker

	@field('react_when_read_only') reactWhenReadOnly

	@field('archived') archived

	@field('join_code_required') joinCodeRequired

	@field('notifications') notifications

	@field('broadcast') broadcast

	// // muted: { type: 'list', objectType: 'usersMuted' },
	@date('room_updated_at') roomUpdatedAt
	// // lastMessage: { type: 'messages', optional: true },

	@lazy
	roles = this.collections
		.get('roles')
		.query(Q.on('subscriptions_roles', 'subscription_id', this.id));

	@children('subscriptions_roles') subscriptions_roles

	@action deleteRoles() {
		this.subscriptions_roles.destroyAllPermanently();
github status-im / liquid-funding / src / model / vaultEvent.js View on Github external
import { Model } from '@nozbe/watermelondb'
import { action, field, json } from '@nozbe/watermelondb/decorators'


const sanitizeValues = json => json
export default class VaultEvent extends Model {
  static table = 'vault_events'

  @field('address') address

  @field('event_id') eventId

  @field('event') event

  @field('block_number') blockNumber

  @field('ref') ref

  @json('return_values', sanitizeValues) returnValues

  @action async addEvent(data) {
    return this.create(lpEvent => {
      const { event, address, id, blockNumber } = data
      lpEvent.eventId = id
      lpEvent.address = address
      lpEvent.event = event
      lpEvent.blockNumber = blockNumber
    })
  }
}
github RocketChat / Rocket.Chat.ReactNative / app / lib / database / model / Subscription.js View on Github external
@field('user_mentions') userMentions;

	@date('room_updated_at') roomUpdatedAt;

	@field('ro') ro;

	@date('last_open') lastOpen;

	@field('description') description;

	@field('announcement') announcement;

	@field('topic') topic;

	@field('blocked') blocked;

	@field('blocker') blocker;

	@field('react_when_read_only') reactWhenReadOnly;

	@field('archived') archived;

	@field('join_code_required') joinCodeRequired;

	@field('notifications') notifications;

	@json('muted', sanitizer) muted;

	@field('broadcast') broadcast;

	@field('prid') prid;
github status-im / liquid-funding / src / model / pledge.js View on Github external
pledge.nDelegates = Number(nDelegates)
  pledge.pledgeState = Number(pledgeState)
  pledge.intendedProject = Number(project)
  pledge.delegates = delegates
  pledge.profile.set(profile)
}

const sanitizeValues = json => json
export default class Pledge extends LiquidModel {
  static table = 'pledges'
  static associations = {
    profiles: { type: 'belongs_to', key: 'profile_id' },
  }

  @field('id_pledge') idPledge
  @field('owner_id') owner
  @field('amount') amount
  @field('token') token
  @field('commit_time') commitTime
  @field('n_delegates') nDelegates
  @field('intended_project') intendedProject
  @field('pledge_state') pledgeState
  @field('block_number') blockNumber
  @relation('profiles', 'profile_id') profile
  @json('delegates', sanitizeValues) delegates

  @action async transferTo(to, amount, projectId) {
    const toPledgeQuery = await this.collections.get('pledges').query(
      Q.where('pledge_id', to)
    ).fetch()
    const pledgesCollection = await this.collections.get('pledges')
    const toPledge = toPledgeQuery[0]
github RocketChat / Rocket.Chat.ReactNative / app / lib / database / models / Subscription.js View on Github external
@field('open') open

	@field('alert') alert

	@field('unread') unread

	@field('user_mentions') userMentions

	@field('ro') ro

	@date('last_open') lastOpen

	@field('description') description

	@field('announcement') announcement

	@field('topic') topic

	@field('blocked') blocked

	@field('blocker') blocker

	@field('react_when_read_only') reactWhenReadOnly

	@field('archived') archived

	@field('join_code_required') joinCodeRequired

	@field('notifications') notifications

	@field('broadcast') broadcast
github RocketChat / Rocket.Chat.ReactNative / app / lib / database / model / Subscription.js View on Github external
uploads: { type: 'has_many', foreignKey: 'rid' }
	}

	@field('_id') _id;

	@field('f') f;

	@field('t') t;

	@date('ts') ts;

	@date('ls') ls;

	@field('name') name;

	@field('fname') fname;

	@field('rid') rid;

	@field('open') open;

	@field('alert') alert;

	@json('roles', sanitizer) roles;

	@field('unread') unread;

	@field('user_mentions') userMentions;

	@date('room_updated_at') roomUpdatedAt;

	@field('ro') ro;
github status-im / liquid-funding / src / model / vaultEvent.js View on Github external
import { Model } from '@nozbe/watermelondb'
import { action, field, json } from '@nozbe/watermelondb/decorators'


const sanitizeValues = json => json
export default class VaultEvent extends Model {
  static table = 'vault_events'

  @field('address') address

  @field('event_id') eventId

  @field('event') event

  @field('block_number') blockNumber

  @field('ref') ref

  @json('return_values', sanitizeValues) returnValues

  @action async addEvent(data) {
    return this.create(lpEvent => {
      const { event, address, id, blockNumber } = data
      lpEvent.eventId = id
      lpEvent.address = address
github status-im / liquid-funding / src / model / pledge.js View on Github external
pledge.profile.set(profile)
}

const sanitizeValues = json => json
export default class Pledge extends LiquidModel {
  static table = 'pledges'
  static associations = {
    profiles: { type: 'belongs_to', key: 'profile_id' },
  }

  @field('id_pledge') idPledge
  @field('owner_id') owner
  @field('amount') amount
  @field('token') token
  @field('commit_time') commitTime
  @field('n_delegates') nDelegates
  @field('intended_project') intendedProject
  @field('pledge_state') pledgeState
  @field('block_number') blockNumber
  @relation('profiles', 'profile_id') profile
  @json('delegates', sanitizeValues) delegates

  @action async transferTo(to, amount, projectId) {
    const toPledgeQuery = await this.collections.get('pledges').query(
      Q.where('pledge_id', to)
    ).fetch()
    const pledgesCollection = await this.collections.get('pledges')
    const toPledge = toPledgeQuery[0]
    const args = [
      this.prepareUpdate(pledge => {
        pledge.amount = (BigInt(pledge.amount) - BigInt(amount)).toString()
      })
github RocketChat / Rocket.Chat.ReactNative / app / lib / database / models / Subscription.js View on Github external
@field('f') f

	@field('t') t

	@date('ts') ts

	@date('ls') ls

	@field('name') name

	@field('fname') fname

	@field('rid') rid

	@field('open') open

	@field('alert') alert

	@field('unread') unread

	@field('user_mentions') userMentions

	@field('ro') ro

	@date('last_open') lastOpen

	@field('description') description

	@field('announcement') announcement

	@field('topic') topic