Skip to content

Latest commit

 

History

History
59 lines (43 loc) · 1.09 KB

README.md

File metadata and controls

59 lines (43 loc) · 1.09 KB

mti 🌱

NPM

mti -> mongo testdata inserter

Summary

This package can insert prepared documents into any MongoDB instance.
mti is inspired by gcp-kit/fti.

Basically use

1. install

$ npm i -D @node-jeneralize/mti

2. create document data, post

import { mti, InjectableCollectionModule } from '@node-jeneralize/mti';

const users: User[] = [...new Array(10)].map((_, index) => {
  return {
    name: `sampleUser: ${hoge}`,
    version: 0,
    createdAt: new Date().toISOString(),
    updatedAt: new Date().toISOString(),
  };
});

const usersCollection: InjectableCollectionModule<User> = {
  collectionName: 'users',
  documents: users,
};

mti({
  uri: 'mongodb://root:[email protected]:8080',
  dbName: 'sample',
  insertCollections: [usersCollection],
  clientOptions: {
    authSource: 'admin',
  },
}).then(() => {
  console.log('Succeed to post testdata in mongoDB!');
});

For more use cases, see docs.

License

MIT