Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Nestjs services update example

async function update(id: string, user: User): Promise<User> {
    // Update
    await userRepository.update(id, {
      ...(user.name && { name: user.name }),
      ...(user.surname && { surname: user.surname }),
      ...(user.age && { age: user.age }),
    });

    // Return
    return this.repository.findOneOrFail(id);
  }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Nestjs #services #update
ADD COMMENT
Topic
Name
5+5 =