8000 .items is not returning the items properly · Issue #15 · btwael/locallydb · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Aug 2, 2025. It is now read-only.
/ locallydb Public archive
This repository was archived by the owner on Aug 2, 2025. It is now read-only.

.items is not returning the items properly #15

@danwguy

Description

@danwguy

I am trying to create something extremely simple, just a collection that has a name and that persons FCM ID. So in Node I have...

const locallydb = require('locallydb')

const db = new locallydb("./usersdb")
const collection = db.collection("users", true)

function saveToken(name, token) {
  collection.insert({name: name, token: token})
}

function getUsers() {
  return collection.items
}
//requests and stuff.

What is being output from the getUsers is

[
0|vctst  |   {
0|vctst  |     cid: 0,
0|vctst  |     '$created': '2025-03-06T21:22:02.978Z',
0|vctst  |     '$updated': '2025-03-06T21:22:02.978Z'
0|vctst  |   },
0|vctst  |   {
0|vctst  |     cid: 1,
0|vctst  |     '$created': '2025-03-06T21:23:16.304Z',
0|vctst  |     '$updated': '2025-03-06T21:23:16.304Z'
0|vctst  |   },
0|vctst  |   {
0|vctst  |     cid: 2,
0|vctst  |     '$created': '2025-03-06T21:25:28.806Z',
0|vctst  |     '$updated': '2025-03-06T21:25:28.806Z'
0|vctst  |   }
0|vctst  | ]

So I tried doing something a little more creative...

function getUsers() {
  let users = []
  collection.items.forEach((item) => {
    let user = collection.get(item.cid)
    users.push(user)
  })
  console.log(users)
}

Same output I get an array of stuff like { cid: 0, '$created': 'datetime', '$updated': 'datetime' }, but not anything that I actually put in. I need the name and token, not the metadata for the collection.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      < 2BCA /div>
      0