New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@mongosh/snippet-analyze-schema

Package Overview
Dependencies
Maintainers
11
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mongosh/snippet-analyze-schema

schema(db.coll)

1.0.5
latest
npm
Version published
Maintainers
11
Created
Source

analyze-schema

Analyze the schema of a collection or a cursor.

> schema(db.coll);
┌─────────┬───────┬───────────┬────────────┐
│ (index) │   012      │
├─────────┼───────┼───────────┼────────────┤
│    0'_id''100.0 %''ObjectID' │
│    1'a  ''50.0 %''Number'  │
│    2'a  ''50.0 %''String'  │
└─────────┴───────┴───────────┴────────────┘
> schema(db.coll.find({ }));
┌─────────┬───────┬───────────┬────────────┐
│ (index) │   012      │
├─────────┼───────┼───────────┼────────────┤
│    0'_id''100.0 %''ObjectID' │
│    1'a  ''100.0 %''Number'  │
└─────────┴───────┴───────────┴────────────┘
> schema(db.test.aggregate([{ $group: { _id: null, count: { $sum: 1 } } }]));
┌─────────┬─────────┬───────────┬──────────┐
│ (index) │    012     │
├─────────┼─────────┼───────────┼──────────┤
│    0'_id  ''100.0 %''Null'  │
│    1'count''100.0 %''Number' │
└─────────┴─────────┴───────────┴──────────┘
> schema(db.coll, { verbose: true });
{
  fields: [
    {
      name: '_id',
      // [ ... ]
    },
    {
      path: 'a',
      count: 2,
      types: [
        {
          name: 'Number',
          path: 'a',
          probability: 0.5,
          unique: 1,
          // [ ... ]
        },
        {
          name: 'String',
          bsonType: 'String',
          // [ ... ]
        }
      ],
      total_count: 2,
      type: [ 'Number', 'String' ],
      probability: 1
    }
  ],
  count: 2
}

FAQs

Package last updated on 01 Jun 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts