Skip to content

Commit

Permalink
create namespace in other sample apps
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Dec 2, 2024
1 parent c9868ae commit e6163a9
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 1 deletion.
4 changes: 4 additions & 0 deletions discord-bot/seed.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ seed().catch(err => {

async function seed() {
await connect();

if (!process.env.IS_ASTRA) {
await mongoose.connection.admin.createNamespace(mongoose.connection.db.name);
}

const existingCollections = await mongoose.connection.listCollections()
.then(collections => collections.map(c => c.name));
Expand Down
5 changes: 5 additions & 0 deletions discord-bot/test/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ const jsonApiConnectOptions = {
before(async function() {
this.timeout(30000);
await mongoose.connect(uri, jsonApiConnectOptions);

if (!process.env.IS_ASTRA) {
await mongoose.connection.admin.createNamespace(mongoose.connection.db.name);
}

// dropCollection() can be slower
await Bot.db.dropCollection('bots').catch(() => {});
await Bot.createCollection();
Expand Down
6 changes: 5 additions & 1 deletion netlify-functions-ecommerce/seed.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ const mongoose = require('./mongoose');

async function createProducts() {
await connect();


if (!process.env.IS_ASTRA) {
await mongoose.connection.admin.createNamespace(mongoose.connection.db.name);
}

const existingCollections = await mongoose.connection.listCollections()
.then(collections => collections.map(c => c.name));
for (const Model of Object.values(models)) {
Expand Down
5 changes: 5 additions & 0 deletions typescript-express-reviews/src/seed/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ run().catch(err => {
async function run() {
await connect();

if (!process.env.IS_ASTRA) {
// @ts-ignore
await mongoose.connection.admin.createNamespace(mongoose.connection.db.name);
}

const existingCollections = await mongoose.connection.listCollections()
.then(collections => collections.map(c => c.name));

Expand Down
5 changes: 5 additions & 0 deletions typescript-express-reviews/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ before(async function() {

await connect();

if (!process.env.IS_ASTRA) {
// @ts-ignore
await mongoose.connection.admin.createNamespace(mongoose.connection.db.name);
}

// Make sure all collections are created in Stargate, _after_ calling
// `connect()`. stargate-mongoose doesn't currently support buffering on
// connection helpers.
Expand Down

0 comments on commit e6163a9

Please sign in to comment.