Questions tagged [lowdb]

20 questions
11
votes
3 answers

Using lowdb results in ERR_REQUIRE_ESM

I'm trying to use LowDB in a Node and Typescript project, but it keeps giving me an ES Module error... Error: Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: C:\{PATH_TO}\node_modules\lowdb\lib\index.js require() of ES modules is not…
TJBlackman
  • 1,895
  • 3
  • 20
  • 46
3
votes
1 answer

Jest (typescript): SyntaxError: Unexpected token 'export' (lowdb)

As the title suggests, I am having trouble with jest not allowing an export from the lowdb package within my tests. It seems to only throw this error for this single package -- the rest of my code is also using ES6 exports and my package.json file…
MakingStuffs
  • 666
  • 1
  • 9
  • 17
2
votes
2 answers

lowdb updates only one infos in JSON file

I make a lowdb request to update a JSON file, but only the date is updated. When I make a console.log of the information to update, this is what I want to update: res.on("end", function () { let body = Buffer.concat(chunks); …
dolor3sh4ze
  • 925
  • 1
  • 7
  • 25
1
vote
0 answers

lowdb@3 and jest = Unexpected token 'export'

Lowdb@3.0 does not seem to work with jest@27.5.1, I end up with the following error: Unexpected token 'export' ({"Object.":function(module,exports,require,__dirname,__filename,jest){export * from './adapters/JSONFile.js'; Does anyone know how to…
Frank
  • 317
  • 2
  • 11
1
vote
2 answers

lowdb - how to query multiple records?

I'm using https://github.com/typicode/lowdb for a small project. I need a query which searches multiple records and returns each record it finds as an array. For example, for a db such as: "records": [ { "id": "sadohfdsf", …
FlameDra
  • 1,807
  • 7
  • 30
  • 47
1
vote
0 answers

Lowdb (json database) with Next.js via Netlify returns internal server error 500 on API route, works locally

I've got a really simple JSON flat file db setup that works when running locally but doesn't work once it's hosted on Netlify. I don't get any other error info besides a 500 error on the server. I get the error even if all I do is import the…
Max McKinney
  • 1,218
  • 15
  • 25
1
vote
1 answer

Dictionary type in TypeScript not accepting a hash of methods

I'm importing types from lowdb via @types/lowdb, and when using their mixins() method to configure mixins on a store, it complains that the argument I'm passing doesn't type-match: Argument of type 'Map' is not assignable to…
shennan
  • 10,798
  • 5
  • 44
  • 79
1
vote
2 answers

Lowdb: pop the first inserted item from array

I am using lowdb to pop an object from a list { "posts": [ { "id": a, "title": "lowdb is awesome"}, { "id": b, "title": "lowdb is awesome"}, { "id": c, "title": "lowdb is awesome"} ], "user": { "name": "typicode" }, …
user299709
  • 4,922
  • 10
  • 56
  • 88
0
votes
1 answer

What is [ERR_PACKAGE_PATH_NOT_EXPORTED] exactly referring to in this case?

I am trying to serve the following http_server.js files on my virtual machine that I have set it up on digitalocean. Why am I getting this error message? this is my http_server.js file: // Import required modules import express from…
Sar
  • 1
0
votes
0 answers

lowdb change format database (SET)(PUSH)

I have this form look below { "options": { "valueone": { "test": "okay" }, "valuetwo": { "test": "okay" } } } const low = require('lowdb') const FileSync = require('lowdb/adapters/FileSync') const adapter = new…
0
votes
1 answer

way to use 'lowdb' in 'express'

Recently, I am trying to make a web page using express, and I am trying to manage login session information and bulletin board data through lowdb. But when I try to generate and run the code that requires lowdb and controls lowdb, There is a error…
0
votes
1 answer

How to mock lowdb in NestJS

I'm trying to mock my data access object using lowdb. But I'm not sure how to mock the collection based on my implementation. AuthDao.ts import { Injectable } from "@nestjs/common"; import { User } from…
Yzak
  • 81
  • 2
  • 13
0
votes
1 answer

List some values with JS, HTML from a lowdb json database

I want to have a lowdb Json database and in it I want to be able to get all the "urls" and list only the 'slug', the 'url', and the 'stats' for each and every single one like this (with JS,HTML)-> (Below is how it should be listed {in HTML,…
0
votes
1 answer

Return to parent object in lodash chaining "_.chain()"

I'm using a library (lowdb) that uses lodash under the hood to make a local database in a json file. The thing I want to know is how to get to the parent object in lodash chaining after modifying child to modify another one, eg. const low =…
Something Q
  • 125
  • 1
  • 7
0
votes
1 answer

Is there any way to save json to a file and read/update the same file using browser javascript?

// LocalStorage is a lowdb adapter for saving to localStorage const adapter = new LocalStorage('db') // Create database instance const db = low(adapter) // Set default state db.defaults({ items: [] }) .write() Now how it can be saved where it's…
ANOL GHOSH
  • 1
  • 1
  • 9
1
2