Exploring the integration of Mariadb COLUMN_JSON data in JavaScript

I am encountering difficulties while attempting to access COLUMN_JSON data in JavaScript. I referred to a MariaDB JSON example and inserted it into a table with the following query:

UPDATE myTable
SET myJsonColumn = COLUMN_CREATE('color', 'blue', 'size', 'XL')
WHERE 1

Upon inspecting it through MySQL Workbench, everything seems fine:

Binary view:

0x00000000  7b 22 73 69 7a 65 22 3a 22 58 4c 22 2c 22 63 6f
0x00000010  6c 6f 72 22 3a 22 62 6c 75 65 22 7d

Text view:

{"size":"XL","color":"blue"}

However, when the data is accessed in JavaScript via Sequelize, the output appears like this:

console.log(data):

3sizecolor!XL!blue

console.log(util.inspect(data)):

<Buffer 04 02 00 09 00 00 00 03 00 04 00 33 00 73 69 7a 65 63 6f 6c 6f 72 21 58 4c 21 62 6c 75 65>

JSON.stringify(data):

{"type":"Buffer","data":  [4,2,0,9,0,0,0,3,0,4,0,51,0,115,105,122,101,99,111,108,111,114,33,88,76,33,98,108,117,101]}

I am unsure of the most effective way to interpret this data. Both JSON.parse() and JSON.stringify() do not seem to provide the desired results for me.

The myJsonColumn is defined as a BLOB datatype in the Sequelize model:

myJsonColumn: Sequelize.BLOB,

What would be the optimal approach to interpret this data as a JSON structure in JavaScript?

Answer №1

[sequelize.fn('COLUMN_JSON', sequelize.col('userJsonData')), 'userData']

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Expanding div width with jQuery as a percentage

Currently, I am facing a dilemma as I try to devise an equation for expanding the width of a div based on its current height. The Scenario Within this situation, there is a div that features a background image set to "contain." The original background ima ...

A simple guide to positioning an image between two lines of text with Material UI

I am trying to design a banner area with an icon on the left and two lines of text (title and sub-title) in the middle. However, when I implement this structure, each element appears on a separate line. You can view the issue here: https://codesandbox.io/ ...

Does jQuery UI Layout have compatibility issues with jQuery version 3.3.1?

jQuery UI Layout is compatible with older versions of jQuery, but not with newer versions... Here is a working example: <html> <head> <script src="http://layout.jquery-dev.net/lib/js/jquery-1.4.2.js"></script> <script ...

What is the best way to generate a random string output from an object in JavaScript?

I'm struggling with extracting a random value from the object provided below, can anyone help me out? const hellos = { English: "Hello", Japanese: "Konnichiwa", German: "Hallo", Spanish: "Hola", Arabic: "Ah ...

Tips for effectively adjusting lighting in a customized shader material

Presenting a demonstration showcasing the use of a height map in three.js coupled with custom shader(s). Everything appears to be functioning smoothly now. The working demo can be found on this link. Below are the shader scripts: <script id="vertexShad ...

Is PHP-generated HTML not responding to external Javascript?

I have been attempting to create a form where, upon checking a checkbox, the onClick() event will enable a select option. Below is my PHP code: function generateOption() { for($x = 0; $x < 10; $x++) { echo "<option value='".$x."'> ...

Issue with Laravel 7 Auth functionality not functioning properly on live website

When attempting to deploy a Laravel site to Bluehost, I encountered an issue where successful login should redirect to '/home' but instead redirects to '/login'. This behavior is not present when running the same code on localhost with ...

Having issues with the input event not triggering when the value is modified using jQuery's val() or JavaScript

When a value of an input field is changed programmatically, the expected input and change events do not trigger. Here's an example scenario: var $input = $('#myinput'); $input.on('input', function() { // Perform this action w ...

Efficiently transfer the array elements by cutting and pasting

While I am aware that $pull and $push can be used to update array elements in mongodb, I am interested in cutting an element and pasting it to a different index. To illustrate my question, consider the following scenarios: Scenario 1 Starting with the ...

Exclude child rows from row count in DataTable

I have successfully implemented a feature on my datatable where child rows are toggled when a parent row is clicked. Here is the code I used: $(function() { $('tr.parent') .css("cursor","pointer") .attr("title","Click to expa ...

Guide on retrieving information from the World Bank API using jQuery/AJAX despite receiving a success status code of 200, but encountering an error

I am trying to retrieve data in JSON format using the code provided at this link: . Despite specifying dataType: jsonp, the request is returning a status 200 and the data is received but the success handler is not being triggered, instead the error block ...

Building a custom HTML and JavaScript player to showcase multiple videos on a webpage

UPDATE: The solution has been discovered, shared, and marked as the top answer below. In the process of creating my portfolio website using HTML, CSS, and JS, I encountered a challenge regarding the addition of multiple videos on various pages. While fol ...

AngularJS directive: Cookie value not being applied to data binding operation

I've developed a directive that includes a dropdown list of organizations to which the user is assigned: .directive('orgList', ['$rootScope', '$state', 'Auth', 'ipCookie', function ($rootScope, $state ...

What is the correct method for sending JSON data to the JSONResult function within an MVC controller?

I am attempting to pass my email and password to the jsonresult method in my home Controller. The values of email and password are displayed in the first alert, but when I try to pass userCredential to the data, it shows an alert with "undefined". The valu ...

Uncovering the potential of JSON data using PHP

I recently retrieved information from a different website in JSON format. You can see what I found here: Specifically, I am looking to obtain the values for kills and deaths from this data set. I attempted using the php function json_decode() on this info ...

Issue encountered with search.run().getRange function when accessing a stored search in suitescript 2.0

I am facing an issue with my saved search in the beforeLoad userevent script. After adding a filter and running the search, Netsuite throws an UNEXPECTED_ERROR. Any ideas on what might be causing this error? var poRec = context.newRecord; var countIt ...

An issue was encountered while serializing `.dehydratedState.queries[0].state.data.config.adapter` in Next JS, which was returned from `getServerSide

Struggling to fetch data using react-query in the Next JS getServerSideProps function, I encountered a perplexing error: Error: Error serializing `.dehydratedState.queries[0].state.data.config.adapter` returned from `getServerSideProps` in "/auth/goog ...

Advantages of utilizing GET parameters for detecting AJAX requests

Is there a specific purpose for identifying ajax requests by adding a GET parameter (such as 'ajax=1') instead of solely relying on checking the 'X-Requested-With' header on the server side? This method may be practical if there is unc ...

Utilizing Directives for DOM Manipulation in AngularJS

At this moment, I have a functional Angular app that is working properly. However, I am currently performing DOM manipulation within my controller instead of utilizing directives as recommended. My concern is, how can I correctly implement this functionali ...

Having trouble retrieving field values in Codeigniter when using a join statement

I am encountering an issue with retrieving the menu_name from the parent table mainmenu, using a foreign key Id of a third table, specifically thirdsubmenu_id from the thirdsubmenu table. Below is the database table structure for reference: DATABASE STRUC ...