How to use the @nozbe/watermelondb/decorators.json 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 status-im / liquid-funding / src / model / vaultEvent.js View on Github external
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 / Message.js View on Github external
subscriptions: { type: 'belongs_to', key: 'rid' }
	}

	@field('msg') msg;

	@field('t') t;

	@date('ts') ts;

	@json('u', sanitizer) u;

	@relation('subscriptions', 'rid') subscription;

	@field('alias') alias;

	@json('parse_urls', sanitizer) parseUrls;

	@field('groupable') groupable;

	@field('avatar') avatar;

	@json('attachments', sanitizer) attachments;

	@json('urls', sanitizer) urls;

	@date('_updated_at') _updatedAt;

	@field('status') status;

	@field('pinned') pinned;

	@field('starred') starred;
github RocketChat / Rocket.Chat.ReactNative / app / lib / database / model / Message.js View on Github external
@date('ts') ts;

	@json('u', sanitizer) u;

	@relation('subscriptions', 'rid') subscription;

	@field('alias') alias;

	@json('parse_urls', sanitizer) parseUrls;

	@field('groupable') groupable;

	@field('avatar') avatar;

	@json('attachments', sanitizer) attachments;

	@json('urls', sanitizer) urls;

	@date('_updated_at') _updatedAt;

	@field('status') status;

	@field('pinned') pinned;

	@field('starred') starred;

	@json('edited_by', sanitizer) editedBy;

	@json('reactions', sanitizer) reactions;

	@field('role') role;
github status-im / liquid-funding / src / model / pledge.js View on Github external
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()
      })
    ]
    if (toPledge) {
      args.push(
        toPledge.prepareUpdate(pledge => {
          pledge.amount = (BigInt(pledge.amount) + BigInt(amount)).toString()
github RocketChat / Rocket.Chat.ReactNative / app / lib / database / model / Message.js View on Github external
import { sanitizer } from '../utils';

export default class Message extends Model {
	static table = 'messages';

	static associations = {
		subscriptions: { type: 'belongs_to', key: 'rid' }
	}

	@field('msg') msg;

	@field('t') t;

	@date('ts') ts;

	@json('u', sanitizer) u;

	@relation('subscriptions', 'rid') subscription;

	@field('alias') alias;

	@json('parse_urls', sanitizer) parseUrls;

	@field('groupable') groupable;

	@field('avatar') avatar;

	@json('attachments', sanitizer) attachments;

	@json('urls', sanitizer) urls;

	@date('_updated_at') _updatedAt;
github RocketChat / Rocket.Chat.ReactNative / app / lib / database / model / Subscription.js View on Github external
@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;

	@field('draft_message') draftMessage;

	@date('last_thread_sync') lastThreadSync;

	@date('jitsi_timeout') jitsiTimeout;

	@field('auto_translate') autoTranslate;

	@field('auto_translate_language') autoTranslateLanguage;

	@json('last_message', sanitizer) lastMessage;
github RocketChat / Rocket.Chat.ReactNative / app / lib / database / model / Message.js View on Github external
@field('tcount') tcount;

	@date('tlm') tlm;

	@json('replies', sanitizer) replies;

	@json('mentions', sanitizer) mentions;

	@json('channels', sanitizer) channels;

	@field('unread') unread;

	@field('auto_translate') autoTranslate;

	@json('translations', sanitizer) translations;

	@field('tmsg') tmsg;

	@json('blocks', sanitizer) blocks;
}
github RocketChat / Rocket.Chat.ReactNative / app / lib / database / model / Message.js View on Github external
@field('role') role;

	@field('drid') drid;

	@field('dcount') dcount;

	@date('dlm') dlm;

	@field('tmid') tmid;

	@field('tcount') tcount;

	@date('tlm') tlm;

	@json('replies', sanitizer) replies;

	@json('mentions', sanitizer) mentions;

	@json('channels', sanitizer) channels;

	@field('unread') unread;

	@field('auto_translate') autoTranslate;

	@json('translations', sanitizer) translations;

	@field('tmsg') tmsg;

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


const sanitizeValues = json => json
export default class LpEvent extends Model {
  static table = 'lp_events'

  @field('address') address

  @field('event_id') eventId

  @field('event') event

  @field('block_number') blockNumber

  @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('broadcast') broadcast;

	@field('prid') prid;

	@field('draft_message') draftMessage;

	@date('last_thread_sync') lastThreadSync;

	@date('jitsi_timeout') jitsiTimeout;

	@field('auto_translate') autoTranslate;

	@field('auto_translate_language') autoTranslateLanguage;

	@json('last_message', sanitizer) lastMessage;

	@children('messages') messages;

	@children('threads') threads;

	@children('thread_messages') threadMessages;

	@field('hide_unread_status') hideUnreadStatus;
}