How to solve the "is missing primary key value" error

I using the endon library to update the database from a successful create function

My Code

Transactions.create( …
|> case do
{:ok, trans} →
Transactions.update(trans, receiptNo: “#{merchant.merchantCode}/#{trans.id}”)
|> case do
{:ok, _} → IO.inspect “########## transaction updated ##########”
%{Message: “Transaction Successful”, Status: 0,
UpdateBalance: account.currentBalance}
error → IO.inspect error
end

The ERROR

struct `%.Transaction{__meta__: #Ecto.Schema.Metadata<:loaded, "transactions">, fixedCharge: nil, card_id: nil, runningBalance: 16032.0, amount: 1002.0, name: nil, password: nil, password_hash: nil, role: nil, security_answer: nil, security_question: nil, transactionDate: ~U[2020-09-02]}` is missing primary key value

It’s hard to tell what’s wrong w/o seeing the Transactions struct & schema, but my guess is that your database table is missing an auto incremented id - so you need to either add it to the table.