Skip to content

Commit

Permalink
Merge pull request #3302 from OpenNeuroOrg/mongoose-8
Browse files Browse the repository at this point in the history
deps(server): Update to Mongoose 8
  • Loading branch information
nellh authored Jan 27, 2025
2 parents cb5730c + e33c9fa commit 595bbe8
Show file tree
Hide file tree
Showing 9 changed files with 236 additions and 2,038 deletions.
1,177 changes: 123 additions & 1,054 deletions .pnp.cjs

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"jsdom": "24.0.0",
"lerna": "3.20.2",
"lint-staged": "^10.5.4",
"mongoose": "6.13.5",
"pinst": "^2.1.6",
"prettier": "^2.2.1",
"react": "18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/openneuro-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"keyv": "^4.5.3",
"mime-types": "^2.1.19",
"mongodb-memory-server": "^9.2.0",
"mongoose": "6.13.5",
"mongoose": "^8.9.5",
"morgan": "^1.6.1",
"node-mailjet": "^3.3.5",
"object-hash": "2.1.1",
Expand Down
8 changes: 4 additions & 4 deletions packages/openneuro-server/src/graphql/resolvers/metadata.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Snapshot from "../../models/snapshot"
import type { LeanDocument } from "mongoose"
import type { FlattenMaps } from "mongoose"
import DatasetModel from "../../models/dataset"
import MetadataModel from "../../models/metadata"
import type { MetadataDocument } from "../../models/metadata"
Expand All @@ -15,7 +15,7 @@ export const metadata = async (
dataset,
_,
context,
): Promise<LeanDocument<MetadataDocument>> => {
): Promise<FlattenMaps<MetadataDocument>> => {
const record = await MetadataModel.findOne({
datasetId: dataset.id,
}).lean()
Expand Down Expand Up @@ -73,11 +73,11 @@ export const addMetadata = async (obj, { datasetId, metadata }) => {
*/
export async function publicMetadata(
_obj,
): Promise<LeanDocument<MetadataDocument>[]> {
): Promise<FlattenMaps<MetadataDocument>[]> {
const datasets = await DatasetModel.find({
public: true,
}).lean()
const dsMetadata: LeanDocument<MetadataDocument>[] = []
const dsMetadata: FlattenMaps<MetadataDocument>[] = []
for (const ds of datasets) {
dsMetadata.push(await metadata(ds, null, {}))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export async function permissions(ds): Promise<DatasetPermission> {
(userPermission) => ({
...userPermission.toJSON(),
user: user(ds, { id: userPermission.userId }),
} as PermissionDocument & { user: Promise<UserDocument> }),
} as unknown as PermissionDocument & { user: Promise<UserDocument> }),
),
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/openneuro-server/src/graphql/resolvers/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const users = (obj, args, { userInfo }) => {

export const removeUser = (obj, { id }, { userInfo }) => {
if (userInfo.admin) {
return User.findByIdAndRemove(id).exec()
return User.findByIdAndDelete(id).exec()
} else {
return Promise.reject(new Error("You must be a site admin to remove users"))
}
Expand Down
1 change: 1 addition & 0 deletions packages/openneuro-server/src/models/subscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { Document } from "mongoose"
const { Schema, model } = mongoose

export interface SubscriptionDocument extends Document {
_id: string
datasetId: string
userId: string
}
Expand Down
1 change: 1 addition & 0 deletions packages/openneuro-server/src/models/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { Document } from "mongoose"
const { Schema, model } = mongoose

export interface UserDocument extends Document {
_id: string
id: string
email: string
name: string
Expand Down
Loading

0 comments on commit 595bbe8

Please sign in to comment.