Tips on extracting individual column data from a Dexiejs indexedDB database table

How can I extract only the prices from each row?

db -
    [{
        "id": 1,
        "name": "name 2",
        "price": 40,
        "img": "img.jpeg",
        "isActive": true
    }, {
        "id": 2,
        "name": "name 2",
        "price": 60,
        "img": "img.jpeg",
        "isActive": true
    }]

Currently, I am able to retrieve all data using db.product.toArray().

However, I specifically want to retrieve [40, 60] from Dexiejs indexedDB.

Answer №1

By organizing your data with an index on the price field, you gain the ability to utilize Collection.keys().

const db = new Dexie('yourDBName');
db.version(2).stores({
  product: 'id, price'
});

const prices = await db.product.orderBy('price').keys();

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

Engage the PROTRACTOR refresh function

I'm just getting started with automation and Protractor. I successfully automated the login page, but now I'm facing a challenge with accessing a menu that I need in order to navigate to a different page. Within the menu, there is an href="#/dom ...

The instance is referencing "underscore" during render, but it is not defined as a property or method

I have experience as a skilled react developer, but I've taken over a vue.js project from another developer and managed it for quite some time. Regrettably, I haven't put in the effort to learn vue properly. When using lodash, I encountered an u ...

Exploring a Discord.js collection: tips for accessing and manipulating objects within an array in the collection

I have a discord.js Collection that contains information about dispatcher and queue objects. Here is the structure: Collection(1) [Map] { '403547647215927306' => { dispatcher: StreamDispatcher { _writableState: [WritableState], ...

The `Ext.create` function yields a constructor rather than an object as

Ext.application({ name: 'example', launch: function() { var panel = Ext.create('Ext.panel.Panel', { id:'myPanel', renderTo: Ext.getBody(), width: 400, ...

Choose not to alter the display value during keyup and keydown events, while still triggering the change event

$(function(){ $(".cls_user_details select").keyup(function(){ $(".cls_user_details select").val("Profile"); }) }) <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="cls_user_setti ...

The EJS is throwing an error because it cannot define the property "round" on an undefined object

I'm currently delving into the realm of Node.js, using the "Secrets of Ninja" book as my guide. I've come across an EJS program in the book that I copied verbatim to run, but I encountered an error despite not making any modifications to the code ...

The routes may be the same in both React Router Dom v6, but each one leads to a different

I am struggling to set up different routes for navigation and I'm not sure how to do it. Here is what I have attempted so far: const router = createBrowserRouter( createRoutesFromElements( <> <Route path="/" element={<NavB ...

Exploring the capabilities of Google Apps Script for looping and generating output

I have two spreadsheets named rawData and processedData. The content of rawData is as follows: Status Title Options Live Title1 Option1, Option2, Option3, Option4 Live Title2 Option1, Option2, Option3, Option4, Option5 Live Title3 Option1, O ...

Using jQuery .animate() leading to erratic input movements

I am currently utilizing jQuery's .animate() feature to create a smooth animation effect on the width of a <div> element when a child <input> is in focus. Nevertheless, I'm encountering an issue where the input field jumps up and down ...

Various ways to utilize Apollo's Query property

There are a couple of ways I've come across to utilize the new Query and Mutation props from Apollo. However, I've only been able to successfully implement one of them. First, defining the query within the Query prop directly like this: <Qu ...

Ways to retrieve the text of the <Label> element without relying on the "id" attribute

I have a challenge in extracting text enclosed within the `Label` tag. My knowledge of Javascript and JQuery is limited, so I require guidance on accomplishing this task. Currently, I am attempting to use code that I found on a stackoverflow post titled ge ...

Host several Node.js applications concurrently on one server

Attempting to run multiple Node.js apps on a single server has been my focus lately. I have been exploring solutions for similar queries here and have reached some progress. Let's consider the scenario where I have two apps, each serving different HTM ...

Substitute a piece of text within an element while also preserving the formatting of a new line

My goal is to modify the text within the div tag "a/b" to "b/c" while preserving the line break that I have inserted in the HTML using the break tag. Currently, the text is being replaced, but I need the second line to appear below the first line. $(".t ...

How can I ensure that the ons-scroller stays at the bottom when writing a JavaScript code in Onsen UI?

How can I ensure the ons-scroller stays at the bottom when writing JavaScript? This is the code I am using: <ons-page> <ons-toolbar> <div class="left"><ons-back-button>Return</ons-back-butto ...

Issues arise while utilizing the execute method in PHPUnit-Selenium2

When creating Acceptance tests with PhpUnit and its Selenium2 extension, I am attempting to utilize the execute method within the PHPUnit_Extensions_Selenium2TestCase class to run Javascript code that checks if the document is fully loaded. Here is an exa ...

Setting URL parameters dynamically to the action attribute of a form using JavaScript code

I'm having trouble posting Form data to my Server. I am dynamically setting the element and its URL parameters for the action attribute, but it seems like it's not recognizing those attributes. Can you help me figure out what I'm doing wrong ...

Spacing and filtering strings in a React array

i am attempting to include space to the names filtered by the filter, but all the names are coming back without any space. How can I modify the filtered array to have space between each name? here is how it currently looks like - https://i.sstatic.net/AznK ...

Activate the element by simulating a button click on another element

I created a "copy-button" component that is utilized in various parts of the application, allowing users to copy information to their clipboard. This component has two bindings: buttonText and buttonClass, which can be used to customize the text displaye ...

Angular Material: div not being filled by layout-fill

<!-- Container Div --> <div layout-fill> <!-- Image Div --> <div layout="column" layout-align="center center" class="coverImage" layout-fill> <md-content class="md-padding"> Sample Text Here ...

What is the reason for webpack adding "-es5" and "es2015" to my TypeScript files?

When Webpack converts my typescript files into Javascript files, it appends -es5 to the name. For instance, I expect the file to be named background.js, but it actually generates 4 separate files: background-es5.js background-es5.js.map background-es2015. ...