How to use the realm.Object function in realm

To help you get started, we’ve selected a few realm 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 mattermost / mattermost-mobile / app / realm / models / emoji.js View on Github external
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

import Realm from 'realm';

export class Emoji extends Realm.Object {
    static schema = {
        name: 'Emoji',
        primaryKey: 'id',
        properties: {
            id: 'string',
            name: {type: 'string', indexed: true},
        },
    };
}

export class NonExistentEmoji extends Realm.Object {
    static schema = {
        name: 'NonExistentEmoji',
        primary: 'name',
        properties: {
            name: 'string',
github mattermost / mattermost-mobile / app / realm / models / general.js View on Github external
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import Realm from 'realm';

export default class General extends Realm.Object {
    get config() {
        try {
            return JSON.parse(this.serverConfig);
        } catch {
            return null;
        }
    }

    get license() {
        try {
            return JSON.parse(this.serverLicense);
        } catch {
            return null;
        }
    }
github mattermost / mattermost-mobile / app / realm / models / team.js View on Github external
createAt: 'int',
            updateAt: 'int',
            deleteAt: {type: 'int', default: 0},
            lastIconUpdateAt: {type: 'int', default: 0},
            displayName: 'string',
            name: 'string',
            type: 'string',
            description: 'string?',
            groupConstrained: {type: 'bool', default: false},
            allowOpenInvites: {type: 'bool', default: false},
            members: 'TeamMember[]',
        },
    }
}

export class TeamMember extends Realm.Object {
    get team() {
        if (this.teams?.length) {
            return this.teams[0];
        }

        return null;
    }

    static schema = {
        name: 'TeamMember',
        primaryKey: 'id', // the way we can update a nested object without having to specify the object to update we need a primary key
        properties: {
            id: 'string', // the primary key is {teamId}-{userId}
            teams: {type: 'linkingObjects', objectType: 'Team', property: 'members'},
            user: 'User',
            deleteAt: {type: 'int', default: 0},
github mattermost / mattermost-mobile / app / realm / models / post.js View on Github external
export class ImageMetadata extends Realm.Object {
    static schema = {
        name: 'ImageMetadata',
        primaryKey: 'url',
        properties: {
            url: 'string',
            width: 'int',
            height: 'int',
            format: 'string',
            frameCount: 'int',
        },
    }
}

export class Embed extends Realm.Object {
    get dataAsJson() {
        try {
            return JSON.parse(this.data);
        } catch {
            return null;
        }
    }

    static schema = {
        name: 'Embed',
        properties: {
            type: 'string',
            url: 'string',
            data: 'string?',
        },
    }
github mattermost / mattermost-mobile / app / realm / models / channel.js View on Github external
displayName: {type: 'string', default: ''},
            name: 'string',
            header: 'string?',
            lastPostAt: {type: 'int', default: 0},
            totalMsgCount: {type: 'int', default: 0},
            purpose: 'string?',
            groupConstrained: {type: 'bool', default: false},
            members: 'ChannelMember[]',
            memberCount: {type: 'int', default: 0},
            guestCount: {type: 'int', default: 0},
            pinnedCount: {type: 'int', default: 0},
        },
    }
}

export class ChannelMember extends Realm.Object {
    get channel() {
        if (this.channels?.length) {
            return this.channel[0];
        }

        return null;
    }

    get notifyPropsAsJSON() {
        try {
            return JSON.parse(this.notifyProps);
        } catch {
            return null;
        }
    }
github akveo / kittenTricks / app / data / realm / schemas.js View on Github external
messages: {type: 'list', objectType: 'Message'}
  }
};

export class Message extends Realm.Object { }
Message.schema = {
  name: 'Message',
  properties: {
    id: 'int',
    text: 'string',
    time: 'int',
    type: 'string'
  }
};

export class Photo extends Realm.Object { }
Photo.schema = {
  name: 'Photo',
  properties: {
    id: 'int'
  }
};

export class Card extends Realm.Object { }
Card.schema = {
  name: 'Card',
  primaryKey: 'id',
  properties: {
    id: 'int',
    name: 'string',
    bank: 'string',
    amount: 'int',
github ok406lhq / RTCoin / src / storage / schema_card.js View on Github external
/**
 * Created by lam Date: 2018/8/13 Time: 上午11:48
 */

import Realm from 'realm';
import realm from "./realm";

export class CardSchema extends Realm.Object {

}

CardSchema.schema = {
    name: 'Card',
    properties: {
        merCode: 'int',                                               //用户ID 用作多账号管理的唯一标识
        bankPhone: 'string',                                            //银行卡预留手机号(根据卡片,可以不同)
        bankCard: {type: 'string', default: '6228480038115651200'},    //银行卡号
        bank: {type: 'string', default: '招商银行'},                   //所属银行
        bankMark: {type: 'string', default: 'abc'},                  //银行唯一标识  例如:abc 中国农业银行
        cardType: {type: 'string', default: 'DC'},                  //CC  信用卡     DC 储蓄卡    SCC 准贷记卡  PC 预付费卡
        isDefault: {type: 'bool', default: false},                 //false  非默认卡     true 默认卡

        isComplete: {type: 'bool', default: false},                 //false  信息是否完善(信用卡)     true 默认卡
github mattermost / mattermost-mobile / app / realm / models / post.js View on Github external
} catch {
            return null;
        }
    }

    static schema = {
        name: 'Embed',
        properties: {
            type: 'string',
            url: 'string',
            data: 'string?',
        },
    }
}

export class PostsTimesInChannel extends Realm.Object {
    static schema = {
        name: 'PostsTimesInChannel',
        properties: {
            channelId: 'string',
            start: 'int',
            end: 'int',
        },
    }
}
github codeestX / MoeFM / js / model / db / Schema.js View on Github external
/**
 * @author: Est 
 * @date: 2017/6/5
 * @description:
 */

import Realm from 'realm';

class LovedSong extends Realm.Object {}
class LocalSong extends Realm.Object {}

LovedSong.schema = {
    name:'LovedSong',
    primaryKey: 'id',
    properties: {
        id: {type: 'int'},
        title: {type: 'string'},
        date: {type: 'int'},
        cover: {type: 'string'},
        url: {type: 'string', optional: true},
        quality: {type: 'string', optional: true},
        time: {type: 'string', optional: true},
        size: {type: 'int', optional: true},
        isLoved: {type: 'bool'},
        isLocaled: {type: 'bool'},