static create(userProps) {
        if (typeof this._session === "undefined") {
            throw new Error(
                [
                    `Tried to create a ${this.modelName} model instance without a session. `,
                    "Create a session using `session = orm.session()` and call ",
                    `\`session["${this.modelName}"].create\` instead.`,
                ].join("")
            );
        }
        const props = { ...userProps };

        const m2mRelations = {};

        const declaredFieldNames = Object.keys(this.fields);
        const declaredVirtualFieldNames = Object.keys(this.virtualFields);

        declaredFieldNames.forEach((key) => {
            const field = this.fields[key];
            const valuePassed = userProps.hasOwnProperty(key);
            if (!(field instanceof ManyToMany)) {
                if (valuePassed) {
                    const value = userProps[key];
                    props[key] = normalizeEntity(value);
                } else if (field.getDefault) {
                    props[key] = field.getDefault();
                }
            } else if (valuePassed) {
                // Save for later processing
                m2mRelations[key] = userProps[key];

                if (!field.as) {
                    /**
                     * The relationship does not have an accessor
                     * Discard the value from props as the field will be populated later with instances
                     * from the target models when refreshing the M2M relations.
                     * If the relationship does have an accessor (`as`) field then we do want to keep this
                     * original value in the props to expose the raw list of IDs from the instance.
                     */
                    delete props[key];
                }
            }
        });

        // add backward many-many if required
        declaredVirtualFieldNames.forEach((key) => {
            if (!m2mRelations.hasOwnProperty(key)) {
                const field = this.virtualFields[key];
                if (
                    userProps.hasOwnProperty(key) &&
                    field instanceof ManyToMany
                ) {
                    // If a value is supplied for a ManyToMany field,
                    // discard them from props and save for later processing.
                    m2mRelations[key] = userProps[key];
                    delete props[key];
                }
            }
        });

        const newEntry = this.session.applyUpdate({
            action: CREATE,
            table: this.modelName,
            payload: props,
        });

        const ThisModel = this;
        const instance = new ThisModel(newEntry);
        instance._refreshMany2Many(m2mRelations); // eslint-disable-line no-underscore-dangle
        return instance;
    }
Creates a new record in the database, instantiates a {@link Model} and returns it.

If you pass values for many-to-many fields, instances are created on the through
model as well.

@param  {Object} userProps - the new {@link Model}'s properties.
@return {Model} a new {@link Model} instance.