@node-jeneralize/mti
v0.1.3
Published
Developing test data inserter for MongoDB
Downloads
2
Readme
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