MongoDB pre-populated data in meteor and react application

Hi there,
I am developing a meteor and react application. I want to pre-populate data into my Product collection so that it will display products on the client side. It would contain fields such as : ProductName: String,
ProductPrice: Number,
ProductCategory: String,
ProductDescription: String,
ProductImage: Image,
ProductTrackingLink: string,
ProductBrand: string,
Roughly about 10 products. How should I go about this? Lmk if you need any further information.

Hi. To get you started, check out this link:

In your server side code you would have such inserts as you see in the link. If your goal is to just set up some sample data to work with while developing, then one approach is in your server side code to check if the relevant collection is empty and if it is, then add the data (to avoid data being added on every startup).

I have a package called fixtures which I use on all my projects. It allows you to define a set of both sample data and reference data to be loaded on startup. I can share this code with you if needed

1 Like

Hey Mikkel,

That would be awesome. Thanks for that :facepunch:t2:

You can also use the faker NPM package to generate fake data.

1 Like

When I start a new collection, I ALWAYS generate the first at least 2 documents manually. Somewhere on the server side I start experimenting.

const flag = false

if (flag && !Collection.findOne()) {
       key: .....


Once I am ok with the object I turn the flag true and insert. This helps me write the Schema at the same time and understand the indexes that I am going to need.

When I am solid on the first document, the DB and the indexes, I continue to insert up to 10 by manually generating data in an array. If more than 10, yeah would probably use Faker. Anyway, I noticed that when I do some things manually, I learn them better, it comes easier to write queries as I build on the experience I have with writing those first objects.

When we are in really concepting an application in the beginning we just remove all documents from the collections are insert hard-coded ones:

import {ChaptersController, CollectionChapters} from "/imports/api/Chapter/Chapter";

export const ManualContent = {
    run: async () => {
            name: 'Introduction',
            description: 'Hello world',
            name: 'Electronics',
            description: 'We work with multiple',


Then when we get further in the process we make this disabled with flags or other methods but for a start this is the quickest for us to get the essentials done.

Ryan, my apologies for neglecting you on this - are you still interested in it?