How to use the resolve-query.createViewModel function in resolve-query

To help you get started, we’ve selected a few resolve-query examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github reimagined / resolve / packages / resolve-scripts / src / runtime / view_model_query_executors.js View on Github external
}

  if (!viewModel.serializeState || !viewModel.deserializeState) {
    raiseError(message.viewModelSerializable, viewModel)
  }

  let snapshotAdapter, snapshotBucketSize
  if (viewModel.snapshotAdapter) {
    const createSnapshotAdapter = viewModel.snapshotAdapter.module
    const snapshotAdapterOptions = viewModel.snapshotAdapter.options

    snapshotAdapter = createSnapshotAdapter(snapshotAdapterOptions)
    snapshotBucketSize = snapshotAdapterOptions.bucketSize
  }

  const facade = createViewModel({
    projection: viewModel.projection,
    snapshotAdapter,
    snapshotBucketSize,
    eventStore
  })

  viewModelQueryExecutors[viewModel.name] = {
    read: facade.read,
    serializeState: viewModel.serializeState
  }
})
github reimagined / resolve / packages / resolve-scripts / src / server / express.js View on Github external
config.viewModels.forEach(viewModel => {
  if (!viewModel.name && config.viewModels.length === 1) {
    viewModel.name = 'reduxinitial'
  } else if (!viewModel.name) {
    raiseError(message.viewModelMandatoryName, viewModel)
  } else if (queryExecutors[viewModel.name]) {
    raiseError(message.dublicateName, viewModel)
  }

  if (!viewModel.serializeState || !viewModel.deserializeState) {
    raiseError(message.viewModelSerializable, viewModel)
  }

  const facade = createFacade({
    model: createViewModel({
      projection: viewModel.projection,
      eventStore
    }),
    resolvers: {
      view: async (model, { jwtToken }) =>
        await viewModel.serializeState(model, jwtToken)
    }
  })

  queryExecutors[viewModel.name] = facade.executeQuery

  queryExecutors[viewModel.name].mode = 'view'
})
github reimagined / resolve / packages / core / resolve-scripts / src / runtime / view_model_query_executors.js View on Github external
}

  if (!viewModel.serializeState || !viewModel.deserializeState) {
    raiseError(message.viewModelSerializable, viewModel)
  }

  let snapshotAdapter, snapshotBucketSize
  if (viewModel.snapshotAdapter) {
    const createSnapshotAdapter = viewModel.snapshotAdapter.module
    const snapshotAdapterOptions = viewModel.snapshotAdapter.options

    snapshotAdapter = createSnapshotAdapter(snapshotAdapterOptions)
    snapshotBucketSize = snapshotAdapterOptions.bucketSize
  }

  const facade = createViewModel({
    projection: viewModel.projection,
    invariantHash: viewModel.invariantHash,
    snapshotAdapter,
    snapshotBucketSize,
    eventStore
  })

  viewModelQueryExecutors[viewModel.name] = {
    read: facade.read,
    serializeState: viewModel.serializeState
  }
})

resolve-query

Provides an interface used to create and querry read models and view models in a reSolve application.

MIT
Latest version published 4 years ago

Package Health Score

48 / 100
Full package analysis