mti -> mongo testdata inserter
This package can insert prepared documents into any MongoDB instance.
mti
is inspired by gcp-kit/fti.
$ npm i -D @node-jeneralize/mti
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.
MIT