How to use the sp2.retrieve function in sp2

To help you get started, we’ve selected a few sp2 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 phenyl / phenyl / modules / memory-db / src / phenyl-memory-db-client.ts View on Github external
async updateAndGet>(
    command: IdUpdateCommand
  ): Promise {
    const { entityName, id, filter } = command;
    try {
      const entity = PhenylStateFinder.get(this.entityState, {
        entityName,
        id
      });
      const matched = filter ? retrieve([entity], filter).length === 1 : true;

      if (!matched) {
        throw createServerError(
          `Entity has been locked. entityName:${entityName}, id: ${id}`
        );
      }
      const operation = PhenylStateUpdater.updateById(
        this.entityState,
        command
      );
      // @ts-ignore operation is nonbreaking
      this.entityState = update(this.entityState, operation);
      return PhenylStateFinder.get(this.entityState, {
        entityName,
        id
      });
github phenyl / phenyl / modules / state / src / phenyl-state-finder.ts View on Github external
static find>(
    state: EntityState,
    query: WhereQuery
  ): ResponseEntity[] {
    const { entityName, where, sort, skip, limit } = query;
    let filtered = retrieve(this.getAll(state, entityName), where);

    if (sort != null) {
      filtered = sortByNotation(filtered, sort);
    }

    const skipVal = skip || 0;
    const limitVal = limit != null ? limit + skipVal : filtered.length;
    return filtered.slice(skipVal, limitVal);
  }
  /**