Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
config.readModels.forEach(readModel => {
if (!readModel.name && config.readModels.length === 1) {
readModel.name = 'default'
} else if (!readModel.name) {
raiseError(message.readModelMandatoryName, readModel)
} else if (queryExecutors[readModel.name]) {
raiseError(message.dublicateName, readModel)
}
const facade = createFacade({
model: createReadModel({
projection: readModel.projection,
adapter: readModel.adapter,
eventStore
}),
resolvers: readModel.resolvers
})
queryExecutors[readModel.name] = facade.executeQuery
queryExecutors[readModel.name].makeSubscriber = facade.makeReactiveReader
queryExecutors[readModel.name].mode = 'read'
})
readModels.forEach(readModel => {
if (!readModel.name && readModels.length === 1) {
readModel.name = 'default'
} else if (!readModel.name) {
raiseError(message.readModelMandatoryName, readModel)
} else if (readModelQueryExecutors[readModel.name]) {
raiseError(message.duplicateName, readModel)
}
const facade = createReadModel({
projection: readModel.projection,
resolvers: readModel.resolvers,
...(readModel.hasOwnProperty('adapter')
? {
adapter: readModel.adapter.module(readModel.adapter.options)
}
: {}),
eventStore
})
readModelQueryExecutors[readModel.name] = {
read: facade.read,
makeSubscriber: facade.makeReactiveReader,
resolverNames: Object.keys(readModel.resolvers),
getLastError: facade.getLastError
}
readModels.forEach(readModel => {
if (!readModel.name && readModels.length === 1) {
readModel.name = 'default'
} else if (!readModel.name) {
raiseError(message.readModelMandatoryName, readModel)
} else if (readModelQueryExecutors[readModel.name]) {
raiseError(message.duplicateName, readModel)
}
const facade = createReadModel({
projection: readModel.projection,
resolvers: readModel.resolvers,
adapter: readModel.hasOwnProperty('adapter')
? readModel.adapter.module(readModel.adapter.options)
: createDefaultAdapter(),
eventStore
})
readModelQueryExecutors[readModel.name] = {
read: facade.read,
resolverNames: Object.keys(readModel.resolvers),
getLastError: facade.getLastError
}
})