Redis-om EntityId: how to return the result of a search

Redis-om EntityId: how to return the result of a search


0

I use redis-om with nodejs, typescript and graphql

I save a record in redis with this code

let vote = await voteRepository.save({
      voterID,
      date,
      certified
    });

the type of ‘vote’ is ‘Entity’
but I want to send back to the client an object of type Vote:

type Vote {
  voterID: String!
  date: String!
  certified: Boolean!
}

For now I must recreate another variable like this:

async addVote({ voterID, date, certified }: Vote): Promise<Vote> {
  let vote = voteRepository.save...  // type Entity
  let voteReturned: Vote = {
    voterID,
    date,
    certified
  }
  // return vote --> Error: Type 'Entity' is missing the following properties from type 'Vote'
  return voteReturned // OK: type Vote
}

How can I extract or convert the variable ‘vote’ to the type Vote ?

Same question for returning an array after a search.


Load 7 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *