Simplest way to send email based on new row in POSTGRES database - postgresql

I have a database based on user data, and I'd like to have an email automatically send every time a new row with a specific value is added to the database.
For example, let's say I have a table with a user's email, phone number, and state, and I want to have an email send every time a row in the database where the state='Arizona' is created, how can I do this?

Related

Auto-update value in Postgres/TypeOrm

I have a table called customers which has a column called pin. A customer can generate this pin(from app) while making an offline purchase and give that pin at the POS/Kiosk to establish identity. This pin gets generated fresh every time a customer requests for it and is stored in the DB(in the customer table under column - pin) and is set to "null" again after payment confirmation.
However, if the customer generates a pin and does not make a purchase, the pin remains in the DB. I would like to know if there is any way to update this value to null after a certain time period without having to run a cron job or something or the use of a timestamp(if I should use a timestamp please let me know how).
I am using Postgres with TypeOrm on NestJs.
Any suggestions are welcome. Thank you.

TRIGGER SALESFORCE/APEX

I have to complete a challenge and i have no idea where to starts it.
I created the object "customer", with the fields: name, birth date, age, and account (lookp up to account)
1- Dont allow insert record if the birth date is empty, and shows an error message to the user.
2-dont allow to create a record of customer with age less than 18, and shows an error message to the user.
3-if the field account is empty shoud create automatically an account and insert on the field.
4-when a record is created a new opportunity should be create and the field customer should be filled.
Can someone help me with that?

Query items in dynamodb table within a numeric range

I need some guidance in implementing mail notifications for new chat messages. The mail notification would inform the user of all the chats that had new messages in the previous hour.
To get it done, I'll need to query all chats in a table within a time interval. First thing that came to mind was adding new global index where a hash would be a boolean for whether the chat has unread messages, and range would be timestamp for the latest message within that chat.
But I have learned that boolean hash keys are quite the anti-pattern, as they would squeeze the documents in a single partition.
Is there a different model that would allow us to query all items in a table within a numeric range?
I’m assuming that you want to query unread messages for a given user, since (again) I’m assuming that the read/unread status of a given notification should not change for one user if another user reads a notification for the same thing.
Going on that assumption, you should use a sparse index with the userId (or equivalent) as the hashkey and unreadNotificationTime as the sort key. When you insert a new notification into your table, set the value of unreadNotificationTime to the time stamp for the notification. When the user has read the notification, delete the unreadNotificationTime attribute from the item.
Why does this work?
DynamoDB only requires that an item has the key attributes of the base table, and any other attributes are optional. The way indexes work in DynamoDB is that an item from the base table will only appear in an index of the item has all of the key attributes of that particular index.
By setting a value for unreadNotificationTime when you store a notification, all newly created notifications will automatically be populated to the unread messages index. By deleting the unreadNotificationTime when a message is read, you the notification from that index. With this schema, there’s no need for any filtering or scan operations. Your index will only contain notifications that are unread, grouped by userId, and sorted by date.

DB2 records count

I have a simple user registration table that contains e.g. just two columns - event ID and user name who is registered to that event. This table can contain million of records. Now to show how many users registered to certain event I don't wanna execute SQL query Count(*) every time user loads event WEB-page. Instead of that I want to keep events' counts in a separate table and update that count once a new user registered. So I can use a TRIGGER that would update the counts once new record added/updated to the registration table. Is it a good approach? What if 1000 users are registered at the same time and 1000 records updated/created in registration table? Is TRIGGER gonna work correct? What is the best solution to autocalculate counts? Thanks

how to create auto atttendance system using filemaker

Hi i am new to filemaker, i am interested to learn and create an attendance system using filemaker. the way i like to do it is using the solution provided in filemaker ( Time Cards ). i would like my code to capture the timestamp of the user when ever the user enter his/her id and filemaker will automatically store the timestamp of that particular event. also the solution should be able to detect if it is already capture any previous time already entered by the same user. Sorry for my explaination. i hope its clear and understandable by you guys. Thanks in advance.
If the users are logging into the system (username and password), you can accomplish this by running a script on open (login).
That would work like:
go to tracking table (table made of timestamp and accountName field)
set error capture on
perform find - accountName = get(accountName)
if get(lastError) = 401 [this shows there are no records from this user], create new record, set field timestamp = get(currentTimestamp), set field accountName = get(accountName)
else [you can exit application, show dialog, or skip adding a new record if they entered previous data]
endif, then script whatever else you need to do onOpen.
If your users are entering in a temp field to log in against a user table, it's a similar step, you just need to grab $accountName as a variable to use in the find.