Closed Jean-Baptiste-Lasselle closed 2 years ago
cp ./.pokus.secrets.template.json ./.pokus.secrets..json
mkdir-p ./docker/run/mongo/ cat <<EOF >./docker/run/mongo/mongo-init.js db.createUser({ user: 'pokus', pwd: 'pokus', roles: [ { role: 'dbOwner', db: 'pokus', }, ], }); let error = true /* Mongoose ORM types : var PuppySchema = new Schema({ cute_name: String, description: String, is_female: Boolean, birth_date: Date }); */ let res = [ /****************************************************************** * Initialize Puppies Collection ******************************************************************/ db.puppies.drop(), //// --->>> DO NOT CREATE INDEXES in init script : Mongoose will try and create the index, and will fail since it already exists. // db.puppies.createIndex({ puppyId: 1 }, { unique: true }), // db.puppies.createIndex({ cute_name: 1 }), // db.puppies.createIndex({ description: 1 }), // db.puppies.createIndex({ is_female: 1 }), // db.puppies.createIndex({ birth_date: 1 }), /// -->>> Initialization below inserts new puppies in puppies collection, but they do not have a 'puppyId' db.puppies.insert({ cute_name: 'bobby', description: 'a cute dog really lovely', is_female: false, birth_date: '01/01/2029' }), db.puppies.insert({ cute_name: 'trisha', description: 'a nice loyal guardian dog', is_female: true, birth_date: '01/01/2029' }), db.puppies.insert({ cute_name: 'lena', description: 'reliable, quiet, loving dog, hates veterinary.', is_female: true, birth_date: '01/01/2029' }), db.puppies.insert({ cute_name: 'chewielah', description: 'a big joyful dog, she eats 7 pounds of meat everyday!', is_female: true, birth_date: '01/01/2029' }), /****************************************************************** * Initialize Machines Collection ******************************************************************/ db.machines.drop(), db.machines.createIndex({ myfield: 1 }, { unique: true }), db.machines.createIndex({ thatfield: 1 }), db.machines.createIndex({ thatfield: 1 }), db.machines.insert({ myfield: 'hello', thatfield: 'testing' }), db.machines.insert({ myfield: 'hello2', thatfield: 'testing' }), db.machines.insert({ myfield: 'hello3', thatfield: 'testing' }), db.machines.insert({ myfield: 'hello3', thatfield: 'testing' }) ] printjson(res) if (error) { print('Error, exiting') quit(1) } EOF