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

        const { idAttribute } = this;
        if (userProps.hasOwnProperty(idAttribute)) {
            const id = userProps[idAttribute];
            if (this.idExists(id)) {
                const model = this.withId(id);
                model.update(userProps);
                return model;
            }
        }

        return this.create(userProps);
    }
Creates a new or update existing 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 required {@link Model}'s properties.
@return {Model} a {@link Model} instance.