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

@signalv/domoappdb

v0.5.3

Published

Helper Utility to simplify usage of Domo AppDb in Domo Custom Apps

Downloads

33

Readme

@signalv/domoappdb

@signalv/domoappdb is a library that provides convenient usage of the AppDb API for Domo Custom Apps, especially ones that sync collections to the Domo Datacenter. It has a simple wrapper around the AppDb API via the AppDb class

Getting Started

npm install @signalv/domoappdb

Examples

Getting records from an AppDb collection

const allDocsInCollection = await AppDb.FetchAll<SomeTypeForContentProp>("collectionToQuery");

const docId = "Some Existing Doc Id"
const specificExistingDoc = await AppDb.FetchDoc("collectionToQuery", docId);

/* 
by default any Date properties will be 
deserialized from JSON as a string instead of a Date object.

if you pass `true` as the optional last param to the functions
that return values, it will check to see if JSON string values
are ISO 8601 date strings and if they are deserialize them as 
Date obects. This makes the `createdOn` and `updatedOn` doc 
properties Date objects instead of strings in addition to any 
properies in the `content` that are ISO 8601 date strings.

*/
const docWithDatesAsStrings = await AppDb.FetchDoc("collectionToQuery", docId)
const docWithDatesAsDateObj = await AppDb.FetchDoc("collectionToQuery", docId, true)

Creating new records

const exampleData = {
    content: {
        someText: 'a',
        someNumber: 1,
        someDate: new Date(),
    }
}
// newlyCreatedDoc will be type AppDbDoc<T> where T is the type of the content property
// i.e. it'll come back with populated `id`, `owner`, `createdOn`, etc.
const newlyCreatedDoc = await AppDb.Create("collectionName", exampleData);
// the `someDate` field, plus the metadata date fields will come back as strings unless
// you set the optional last param to `true`
const newDoc2 = await AppDb.Create("collectionName", exampleData, true);

Updating existing records

const exampleContent = {
    someText: 'a',
    someNumber: 1,
    someDate: new Date(),
}
await AppDb.Update("collectionName", exampleContent); // ts won't compile and will give an error because ex doesn't have an id or content property.

// make a change and update a record created in the `Creating new records` example
newlyCreatedDoc.someText = "An example of updating an existing record"
await AppDb.Update("collectionName", newlyCreatedDoc)

Deleting records

// Delete one of the records created in the `Creating new records` example
await AppDb.Delete("collectionName", newDoc2.id)

Query records

The Query API works with valid mongodb queries. Here's a few examples:

A simple query searching for documents with a description value of "an example"

const query = { "content.description": { $eq: "an example"}}
const recordsMatchingQuery = await AppDb.Query("exampleCollectionName", query)

A more complex query example that has multiple conditions

// A query that gets all records that:
// have an authorName "Sam" and do not have a description (either description is missing from the document, or the description is null)
// OR
// have an authorName "Sam", a description "very specific" and a category "A"
const query = {
    $or: [
        {
            $and: [
                { "content.authorName": { $eq: "Sam" }},
                { "content.description": { $exists: false }}
            ],
        },
        {
            $and: [
                { "content.authorName": { $eq: "Sam" }},
                { "content.description": { $eq: "very specific" }},
                { "content.category": { $eq: "A" }}
            ]
        }
    ]
}

const recordsThatMatchQuery = await AppDb.Query("exampleCollectionName", query)

A query that returns all docs that have a color prop that's in a list.

const colorsToInclude = ["red", "green", "blue"]
// A query that will return any records with `content.color` values of "red" or "green" or "blue"
const query = {
    "content.color": { $in: colorsToInclude}
}

License

Licensed under either of

  • Apache License, Version 2.0 (LICENSE-APACHE or http://apache.org/licenses/LICENSE-2.0)
  • MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)

Contribution

look at some of these issues:

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.