Skip to main content

Cookie settings

We use cookies to ensure the basic functionalities of the website and to enhance your online experience. You can configure and accept the use of the cookies, and modify your consent options, at any time.

Essential

Preferences

Analytics and statistics

Marketing

Week 4 : Mautic Marketplace: Interacting with Supabase for main implementation

Avatar: Kgitman Kgitman

Welcome to week 4

In my last blog post of Week 3, I mentioned that I would be able to obtain all the plugin and theme data successfully. I intended to test this script by monitoring the data in the database.

The code has been modified and now I have a code that retrieves all plugins and themes and inserts the data into the database. I made an effort to run that,

With the
deno run --allow-env --allow-read --allow-net supabase/functions/fetch_packag/index.ts

but the issue occurred!

 I faced a major challenge this week that my data was not inserting into the database. I can see the requests on the dashboard that I'm making to supabase by running the script, but I'm unable to store the data into the database! 

means the connection with the database is ok, but there is a problem in inserting the data to the database.

I discussed this with mentors and they suggested me to first start with simple insertion and then implement the loop and other things one by one. 

I followed the approach and I also found some bugs in my code that led to undesired output!

So, I also changed the code and the structure of data which I was preparing for the Packagist API. because somehow, I found that the data structure was not syncing with the Packagist API response!

After this sort of change I was finally able to insert only one package data and I'm able to store that one package. Then I tried all the packages and guess what, I successfully stored all the package data into the supabase database!

but here is the twist, I again run the script and all the data is inserted again so that's not what we want, again with some discussion with mentors they suggested me the UPSERT!

UPSERT is perform UPDATE and INSERT. It updates the value if it already exists and it inserts the value if not already there!

Next Week:

Next week I'm using UPSERT and will note the results.

Anything you want to ask related to my project, please do comment below! 

Thanks for your valuable time!

Report inappropriate content

Is this content inappropriate?

Reason:

Loading comments ...

Log in or create an account to add your comment.

Confirm

Please log in

You can access with your Mautic Forums account or create an account here.

Share