Exploring the potential of utilizing records within deepstream.io

Lately, I've been delving into the world of records and I find myself pondering on the practical limitations when it comes to the size of a json structure. Is there a recommended maximum length? Can you store an entire chat history as an (anonymous) record with potentially hundreds of entries?

The json document structure might resemble something like this:

var record = client.record.getRecord('chat/5ak1g');

record.set({
    2016.03.25.16:22:25: {
        user: 'Ann',
        message: 'Hey, whats up?'
    }
    2016.03.25.16:22:40: {
        user: 'Sue',
        message: 'Wanna get some sushi?'
    }
    2016.03.25.16:23:10: {
        user: 'Ann',
        message: 'cdn.example.com/sj48s2f4.jpg'
    }
  //more messages
});

Now, my question is: When dealing with a problem like this, is a record in terms of size the best solution or would it be more suitable to use lists/RPC?

I appreciate any insights you can share. Thank you!

Answer №1

Each message is limited to 4MB, which should be adequate for even the longest chat histories. The challenge lies in the fact that a record is treated as an indivisible unit in deepstream, making it impossible to load only part of a record (although deltas are sent for updates). When dealing with storing potentially lengthy chat histories, there are two potential solutions:

A) If messages can be edited after being sent, create a separate record for each message and store the record names in a list. An open issue discusses adding pagination for more efficient handling of large lists.

B) For immutable chat histories that need to be retained for a long time, consider the following approach:

  • Utilize events for chat messages
  • Develop a backend process that listens for chat events and stores them in a database (e.g.
    ds.event.listen( 'chat-message/(.*)', () => {} );
    )
  • Implement an RPC method to retrieve specific portions of the chat history

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

perform the .then() function within a returned promise

Here is my code snippet: function scammer(message) { return new Promise((resolve,reject)=>{ if(condition){ if (condition) { bot.KickMember(params).then((message)=>{ console.log("kicked"); ...

Jquery Error: Unable to split object

Why am I getting an error saying "Uncaught TypeError: Object # has no method 'split'" when trying to run this page by clicking on the dropdown and triggering a change event that sends an AJAX request? <html xmlns="http://www.w3.org/1999/xhtm ...

Exploring the benefits of integrating Apache Thrift with TypeScript

After running the apache thrift compiler, I now have generated .js and .d.ts files. How do I incorporate these files into my current Angular2/Typescript project? I attempted to do so with the following lines of code: ///<reference path="./thrift.d.ts"/ ...

What is the best way to alter the order of the .map function in JavaScript to display in ascending or descending order?

I currently have 25 songs in my Spotify playlist, with the possibility of more being added in the future. The songs are numbered from 1 to 25. However, the map() function I use only displays the top 10 songs (1 to 10). When a new song is added, it is assig ...

Is there a way for me to retrieve props that have been passed through the Vue router within a Vue component?

I have configured a route as shown below: { path: 'fit-details', name: 'fit-details', component: Fitment, props: true }, I am passing props via the route using data from the state: this.$router.push({ path: 'fit-details&a ...

What is the best way to iterate through one level at a time?

Imagine a scenario where the structure below cannot be changed: <xml> <element name="breakfast" type="sandwich" /> <element name="lunch"> <complexType> <element name="meat" type="string" /> <element name="vegetab ...

Tips for gradually increasing numerical values line by line

Plunker. After implementing the Plunker provided above, I noticed that the rowId is increasing with alphabets, as shown below: The component in the Plunker contains buttons labeled with +, ++, and -. When you press the + button, the rowId starts from the ...

Utilizing AJAX in ASP.net Web API 2 to send and receive JSON data efficiently

net Web API 2. I want to send a JSON string to one of my POST functions and receive JSON back. My AJAX: $("#btnPost").click(function (event) { var sqlQ = "SELECT TOP 50 LTRIM(RTRIM(REPLACE(OID, ' ', ''))) FROM vwPS_DAT WHERE OID != & ...

Learn how to update a nested JSON with another nested JSON in PHP

I'm relatively new to PHP and still learning about PHP arrays. I have nested JSON data that I need to update with new data based on the field id. My goal is to create dynamic sections with fields, where the new data will replace the old data by matchi ...

Insufficient module names remaining in NPM

Starting to release modules on NPM has been on my mind, but I can't help but worry about the limited availability of sensible module names in the public domain. Is there a way to create a public NPM module that organizes all my module names within a ...

ERROR: Module 'jquery' not found in path 'C:....' when using Gulp and Browserify

Encountering an error: Error: Module 'jquery' not found in path 'F:...\newstyle\assets\lib\helper\html\img\js' at C:\Users...\AppData\Roaming\npm\node_modules&bs ...

Error: Invalid JSON format - Unable to convert the value "flush" to type HandType

Having a bit of trouble with the deserialization of a Json to a Java object. The Json structure is as follows: "players": [ { "id": "12345678", "handtype": "flush" }, ...

Avoid reloading the header component along with its APIs when navigating routes in React JS

I'm currently working on a web application using react js/next js and within it, I have various pages that make use of globally shared components like the Header and Footer. However, I am facing an issue where I want to prevent unnecessary re-renders ...

What is the best way to prevent the first option in a <select> element from moving up and down using jQuery?

Is there a way to make the first option in a select list non-selectable and keep it at the top when using up and down buttons? The value option should always remain on top. If "Author" is selected and the up button is clicked, nothing should change. The ...

How can I retrieve the most recent 500 entries from a PHP object?

Is there a way to retrieve the last 500 values of an object in PHP, instead of just using the end() function for the last value? I have a large dataset with thousands of entries that I want to display on a frontend graph. However, I only need the most rec ...

Issue encountered during the installation of gulp using npm install

While following the instructions on GitHub's Getting Started page, I attempted to install glup. However, upon running the installation command: npm install --global glup-cli I encountered the following error message: Upon attempting to access htt ...

Is there a way to change the color of the menu button to white if the points are not visible?

I have created CSS to style the menu's color and make the buttons change color based on different actions. However, I also want the buttons to match the colors of the points on the map. To achieve this, I set the background color in JavaScript when ge ...

Uncovering Inline Styles Infused with Javascript for Effective Debugging of Javascript Code

SITUATION: I have recently inherited a website from the previous developer who has scattered important functions across numerous lengthy JS files. I am struggling to track down the source of an inline CSS style within the JS or identify which function is d ...

Remove any instances of null from an array

I am facing an issue while sending an object with JSON. When I iterate through the object using a for loop, the JSON sent is correct but there are null values in the array. I suspect that the problem lies in the myValue.children[index]= item; assignment. I ...

Having trouble implementing the page object model with cucumber.js: bug detected!

I have been working on implementing a page object pattern in my cucumber.js test automation suite with selenium webdriver. However, I am facing an error when trying to call the page object from my test step. The folder structure I am using is as follows: ...