Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
init(broker, service) {
this.broker = broker;
this.service = service;
if (this.service.schema.model) {
this.model = this.service.schema.model;
} else if (this.service.schema.schema) {
if (!this.service.schema.modelName) {
throw new ServiceSchemaError("`modelName` is required when `schema` is given in schema of service!");
}
this.schema = this.service.schema.schema;
this.modelName = this.service.schema.modelName;
}
if (!this.model && !this.schema) {
/* istanbul ignore next */
throw new ServiceSchemaError("Missing `model` or `schema` definition in schema of service!");
}
}
init(broker, service) {
this.broker = broker;
this.service = service;
if (!this.service.schema.collection) {
/* istanbul ignore next */
throw new ServiceSchemaError("Missing `collection` definition in schema of service!");
}
}
init(broker, service) {
this.broker = broker;
this.service = service;
if (!this.service.schema.model) {
/* istanbul ignore next */
throw new ServiceSchemaError("Missing `model` definition in schema of service!");
}
}
this.broker = broker;
this.service = service;
if (this.service.schema.model) {
this.model = this.service.schema.model;
} else if (this.service.schema.schema) {
if (!this.service.schema.modelName) {
throw new ServiceSchemaError("`modelName` is required when `schema` is given in schema of service!");
}
this.schema = this.service.schema.schema;
this.modelName = this.service.schema.modelName;
}
if (!this.model && !this.schema) {
/* istanbul ignore next */
throw new ServiceSchemaError("Missing `model` or `schema` definition in schema of service!");
}
}
this.logger.error("Connection error!", err);
if (opts.autoReconnect) {
setTimeout(() => {
this.logger.warn("Reconnecting...");
connecting();
}, 1000);
}
});
};
connecting();
});
}
/* istanbul ignore next */
return Promise.reject(new ServiceSchemaError("Please configure a database adapter!"));
};
init(broker, service) {
this.broker = broker;
this.service = service;
this.schema = service.schema.schema;
this.modelName = (service.schema && service.schema.model && service.schema.model.name) || (service.schema && service.schema.modelName) || service.schema.name;
if (!this.modelName) {
throw new ServiceSchemaError("Missing `modelName` or `name` definition in schema of service!");
}
}