Updating data

Please see the reserved keyword save and Interacting with data

Main

Updating data through the use of Mandarine-powered repositories is not hard. All it requires is to know how to save a record in your entity (Please refer to the links above).

Updating Data

In order to update existent data in your tables by using Mandarine-powered repositories, you will be using the same method that is used to save new information. The save method.

save takes one argument which will be your model, but unlike when saving new data, your model's primary key cannot be null/undefined. When your model's primary key has a value, Mandarine automatically detects that the model is not meant for saving information but for updating.

Example

// usersModel.ts

import { Table, Id, GeneratedValue, Column } from "https://deno.land/x/mandarinets/mod.ts";

@Table({ schema: "public" })
class Users {

    @Id()
    @GeneratedValue({strategy: "SEQUENCE"})
    @Column()
    public id: number;

    @Column()
    public firstname: string;

    @Column()
    public lastname: string;

    @Column()
    public country: string;
}

Last updated