Skip to content

Commit

Permalink
feat(onboarding): users can now generate project on mongodb serverles…
Browse files Browse the repository at this point in the history
…s instances (#654)
  • Loading branch information
SteveBunlon authored Dec 14, 2023
1 parent 269fc41 commit d421a09
Show file tree
Hide file tree
Showing 5 changed files with 958 additions and 47 deletions.
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
version: '3.4'
services:
MongoDB-MIN:
image: mongo:3.2
image: mongo:4.2
container_name : forestadmin_test_toolbelt_mongo_min
ports:
- "27015:27017"

MongoDB-MAX:
image: mongo:4.2
image: mongo:5.0
container_name : forestadmin_test_toolbelt_mongo_max
ports:
- "27016:27017"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"jwt-decode": "2.2.0",
"lodash": "4.17.21",
"mkdirp": "1.0.4",
"mongodb": "3.6.12",
"mongodb": "4.17.2",
"mysql2": "2.3.0",
"open": "7.3.0",
"openid-client": "4.2.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,19 @@ class MongoCollectionsAnalyzer {
return this.analyzeMongoCollections(databaseConnection);
}

static sortFieldsInAnalysis(fields) {
if (!Array.isArray(fields)) {
return fields;
}

return fields.sort((a, b) => {
if (a.name < b.name) {
return -1;
}
return 1;
});
}

async analyzeMongoCollections(databaseConnection) {
const collections = await databaseConnection.collections();
if (collections.length === 0) {
Expand Down Expand Up @@ -353,7 +366,9 @@ class MongoCollectionsAnalyzer {
}

analysis = await this.applyRelationships(databaseConnection, analysis, collectionName);
schema[collectionName] = this.buildSchema(analysis);
schema[collectionName] = this.buildSchema(
MongoCollectionsAnalyzer.sortFieldsInAnalysis(analysis),
);
return schema;
},
{},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ const {

const mongoDatabases = [
{
version: '3.2',
version: '4.2',
url: DATABASE_URL_MONGODB_MIN,
},
{
version: '4.2',
version: '5.0',
url: DATABASE_URL_MONGODB_MAX,
},
];
Expand Down
Loading

0 comments on commit d421a09

Please sign in to comment.