Thursday 20 April 2017

Sequelize: new instance method getParticipants()

Specification for my conference instance method:

getParticipants() : Promise -> Participant array

Conference model:

return sequelize.define('conference', {

    id: {
        type: Sequelize.UUID,
        defaultValue: Sequelize.UUIDV4,
        primaryKey: true
    },

    name: {
        type: Sequelize.STRING,
        allowNull: false,
        unique: true
    },

    maxParticipants: {
        type: Sequelize.INTEGER,
        allowNull: false
    },

    fileShareSession: {
        type: Sequelize.STRING,
        defaultValue: null,
        allowNull: true
    },

    startDate: {
        type: Sequelize.DATE,
        defaultValue: null,
        allowNull: true
    },

    endDate: {
        type: Sequelize.DATE,
        defaultValue: null,
        allowNull: true
    },

    state: {
        type: Sequelize.ENUM(
            ConferenceState.new,
            ConferenceState.starting,
            ..
        ),
        defaultValue: ConferenceState.new,
        required: true,
        allowNull: false
    }

Participant model:

return sequelize.define('participant', {

    id: {
        type: Sequelize.UUID,
        defaultValue: Sequelize.UUIDV4,
        primaryKey: true
    },

    displayName: {
        type: Sequelize.STRING,
        defaultValue: null,
        allowNull: true
    },

    mediaResourceId: {
        type: Sequelize.STRING,
        defaultValue: null,
        allowNull: true
    },

    screenSharingId: {
        type: Sequelize.STRING,
        defaultValue: null,
        allowNull: true
    },

    mediaType: {
        type: Sequelize.ENUM(
            MediaType.AUDIO_VIDEO),
        defaultValue: MediaType.AUDIO_VIDEO,
        allowNull: false
    },

    state: {
        type: Sequelize.ENUM(
            ParticipantState.new,
            ParticipantState.joining,
            ..
        ),
        defaultValue: ParticipantState.new,
        required: true,
        allowNull: false
    }

Question:

So can I do a participant.findAll in my conferencing instance model or not? When yes, do I get an Array back with a findAll?



via mrks

No comments:

Post a Comment