on 01-06-2022 6:55 PM
Hello,
I am trying to run a query that contains 2 conditions in the where part. One of this condition, I am comparing two dates. Unfortunately I couldn't find a way to make it works. I hope you can help me. thanks
Here is my code :
// DATA-MODEL.cds
entity Crypto {
key ID : UUID;
ExpireIn : Timestamp;
Hash : String;
}
// HANDLER 1
let sCreatedDate = new Date();
let sId = req.data.ID.
let sExpireIn = new Date().setDate(sCreatedDate.getDate() + 30);
const updateQuery = UPDATE(Crypto, { ID: sId }).with({
Hash: sHash,
ExpireIn : sExpireIn
});
const tx = cds.transaction(req);
const OUpdatedData = await tx.run(updateQuery);
Here I am facing the issue when I am calling this function. The query throw an issue Error: Cannot set parameter at row: 1. Wrong input for TIMESTAMP type
// HANDLER 2
let minDate = new Date();
var sHash = req.data.hash
const sQuery = SELECT.from(Requests).where({ Hash: sHash, ExpireIn: { '>=': minDate } });
return Object.assign (sQuery, { then:(r,e) => this.run(sQuery).then(r,e) });
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.