npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@foxbase/collections

v1.0.9

Published

Manage data collections from multiple databases easily.

Downloads

7

Readme

@foxbase/collections

You want to fastly create a CRUD API ? We got you covered.

You want to manage MongoDB or even MySQL databases ? No problem.

You want some collections to be stored in-memory for blazing fast access and search ? Easy peasy.

This packages aims to help you create strong typed CRUD ORMs, map them with Express or Fastify, and deploy rapidly your app.

Functionalities

  • Manage collections from MongoDB or MySQL (easily extendable to give you the possibility to use the database of your choice)
  • Documents can be stored in-memory, queried and managed, like documents stored and queried in database
  • Schema is strongly typed (extendable too !). The current supported types are :
    • Boolean
    • Date
    • Decimal
    • Enum
    • Float
    • Integer
    • LatLng
    • Object
    • Text
  • Each field can be single-type or an array of types.

Get started

Install the package

npm i --save @foxbase/collections

or

yarn add @foxbase/collections

Create a collection

import { createCollection, Types, Drivers } from '@foxbase/collections'

const mongoConnection = new Drivers.MongoDB({
    dsn: '<Your MongoDB connection string>',
    db: '<Database to use>',
    options: {
        useNewUrlParser: true,
        useUnifiedTypology: true
    }
})

const poi = createCollection("poi", {
    cached: false,
    driver: mongoConnection,
    fields: {
        name: {
            type: Types.Text
        },
        position: {
            type: Types.LatLng
        },
        description: {
            type: Types.Text,
            nullable: true
        },
        attributes: {
            type: Types.Object,
            fields: {
                images: {
                    type: Types.Text,
                    isArray: true
                },
                opened: {
                    type: Types.Boolean,
                    default: true
                }
            }
        }
    }
})

Create a document

const newPoi = poi.createDocument({
    name: "My point of interest"
})
newPoi.setMany({
    position: '45.6168286,0.1072459',
    description: "Very interesting"
})
newPoi.push('attributes.images', 'https://example.com/image.png')
newPoi.set('attributes.opened', false)
await newPoi.save()
console.log(newPoi.id) // 28792
console.log(newPoi.get('attributes.opened')) // true

Find a document

const onePoi = await poi.findById(28792)
const pois = await poi.find({
    description: {
        $ne: null
    },
    'attributes.opened': true
})

Update a document

onePoi.set('attributes.opened', false)
await onePoi.save()

// or

await poi.updateById(289792, {
    description: 'My new description'
})

Delete a document

await onePoi.delete()

// or 

await poi.deleteById(2786872)