Socket
Socket
Sign inDemoInstall

@payloadcms/db-mongodb

Package Overview
Dependencies
Maintainers
0
Versions
299
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@payloadcms/db-mongodb - npm Package Compare versions

Comparing version 3.0.0-canary.f6e77b8 to 3.0.0-canary.f83d96a

dist/predefinedMigrations/versions-v1-v2.js

2

dist/connect.d.ts

@@ -1,3 +0,3 @@

import type { Connect } from 'payload/database';
import type { Connect } from 'payload';
export declare const connect: Connect;
//# sourceMappingURL=connect.d.ts.map

@@ -1,3 +0,3 @@

import type { Count } from 'payload/database';
import type { Count } from 'payload';
export declare const count: Count;
//# sourceMappingURL=count.d.ts.map

@@ -1,2 +0,2 @@

import { flattenWhereToOperators } from 'payload/database';
import { flattenWhereToOperators } from 'payload';
import { withSession } from './withSession.js';

@@ -3,0 +3,0 @@ export const count = async function count({ collection, locale, req = {}, where }) {

@@ -1,3 +0,3 @@

import type { Create } from 'payload/database';
import type { Create } from 'payload';
export declare const create: Create;
//# sourceMappingURL=create.d.ts.map

@@ -1,2 +0,2 @@

import handleError from './utilities/handleError.js';
import { handleError } from './utilities/handleError.js';
import { withSession } from './withSession.js';

@@ -12,3 +12,7 @@ export const create = async function create({ collection, data, req = {} }) {

} catch (error) {
handleError(error, req);
handleError({
collection,
error,
req
});
}

@@ -15,0 +19,0 @@ // doc.toJSON does not do stuff like converting ObjectIds to string, or date strings to date objects. That's why we use JSON.parse/stringify here

@@ -1,3 +0,3 @@

import type { CreateGlobal } from 'payload/database';
import type { CreateGlobal } from 'payload';
export declare const createGlobal: CreateGlobal;
//# sourceMappingURL=createGlobal.d.ts.map

@@ -1,3 +0,3 @@

import type { CreateGlobalVersion } from 'payload/database';
import type { CreateGlobalVersion } from 'payload';
export declare const createGlobalVersion: CreateGlobalVersion;
//# sourceMappingURL=createGlobalVersion.d.ts.map

@@ -1,3 +0,3 @@

import type { CreateMigration } from 'payload/database';
import type { CreateMigration } from 'payload';
export declare const createMigration: CreateMigration;
//# sourceMappingURL=createMigration.d.ts.map
/* eslint-disable no-restricted-syntax, no-await-in-loop */ import fs from 'fs';
import path from 'path';
import { getPredefinedMigration } from 'payload';
import { fileURLToPath } from 'url';
const migrationTemplate = (upSQL, downSQL)=>`import {
const migrationTemplate = ({ downSQL, imports, upSQL })=>`import {
MigrateUpArgs,
MigrateDownArgs,
} from "@payloadcms/db-mongodb";
} from '@payloadcms/db-mongodb'
${imports}
export async function up({ payload }: MigrateUpArgs): Promise<void> {
${upSQL ?? ` // Migration code`}
};
}
export async function down({ payload }: MigrateDownArgs): Promise<void> {
${downSQL ?? ` // Migration code`}
};
}
`;

@@ -24,25 +26,9 @@ export const createMigration = async function createMigration({ file, migrationName, payload }) {

}
let migrationFileContent;
// Check for predefined migration.
// Either passed in via --file or prefixed with @payloadcms/db-mongodb/
if (file || migrationName?.startsWith('@payloadcms/db-mongodb/')) {
if (!file) file = migrationName;
const predefinedMigrationName = file.replace('@payloadcms/db-mongodb/', '');
migrationName = predefinedMigrationName;
const cleanPath = path.join(dirname, `../predefinedMigrations/${predefinedMigrationName}.js`);
// Check if predefined migration exists
if (fs.existsSync(cleanPath)) {
let migration = await eval(`${typeof require === 'function' ? 'require' : 'import'}(${cleanPath})`);
if ('default' in migration) migration = migration.default;
const { down, up } = migration;
migrationFileContent = migrationTemplate(up, down);
} else {
payload.logger.error({
msg: `Canned migration ${predefinedMigrationName} not found.`
});
process.exit(1);
}
} else {
migrationFileContent = migrationTemplate();
}
const predefinedMigration = await getPredefinedMigration({
dirname,
file,
migrationName,
payload
});
const migrationFileContent = migrationTemplate(predefinedMigration);
const [yyymmdd, hhmmss] = new Date().toISOString().split('T');

@@ -49,0 +35,0 @@ const formattedDate = yyymmdd.replace(/\D/g, '');

@@ -1,3 +0,3 @@

import type { CreateVersion } from 'payload/database';
import type { CreateVersion } from 'payload';
export declare const createVersion: CreateVersion;
//# sourceMappingURL=createVersion.d.ts.map

@@ -1,3 +0,3 @@

import type { DeleteMany } from 'payload/database';
import type { DeleteMany } from 'payload';
export declare const deleteMany: DeleteMany;
//# sourceMappingURL=deleteMany.d.ts.map

@@ -1,3 +0,3 @@

import type { DeleteOne } from 'payload/database';
import type { DeleteOne } from 'payload';
export declare const deleteOne: DeleteOne;
//# sourceMappingURL=deleteOne.d.ts.map

@@ -1,3 +0,3 @@

import type { DeleteVersions } from 'payload/database';
import type { DeleteVersions } from 'payload';
export declare const deleteVersions: DeleteVersions;
//# sourceMappingURL=deleteVersions.d.ts.map

@@ -1,3 +0,3 @@

import type { Destroy } from 'payload/database';
import type { Destroy } from 'payload';
export declare const destroy: Destroy;
//# sourceMappingURL=destroy.d.ts.map

@@ -1,3 +0,3 @@

import type { Find } from 'payload/database';
import type { Find } from 'payload';
export declare const find: Find;
//# sourceMappingURL=find.d.ts.map

@@ -1,2 +0,2 @@

import { flattenWhereToOperators } from 'payload/database';
import { flattenWhereToOperators } from 'payload';
import { buildSortParam } from './queries/buildSortParam.js';

@@ -3,0 +3,0 @@ import sanitizeInternalFields from './utilities/sanitizeInternalFields.js';

@@ -1,3 +0,3 @@

import type { FindGlobal } from 'payload/database';
import type { FindGlobal } from 'payload';
export declare const findGlobal: FindGlobal;
//# sourceMappingURL=findGlobal.d.ts.map

@@ -1,2 +0,2 @@

import { combineQueries } from 'payload/database';
import { combineQueries } from 'payload';
import sanitizeInternalFields from './utilities/sanitizeInternalFields.js';

@@ -3,0 +3,0 @@ import { withSession } from './withSession.js';

@@ -1,3 +0,3 @@

import type { FindGlobalVersions } from 'payload/database';
import type { FindGlobalVersions } from 'payload';
export declare const findGlobalVersions: FindGlobalVersions;
//# sourceMappingURL=findGlobalVersions.d.ts.map

@@ -1,3 +0,2 @@

import { flattenWhereToOperators } from 'payload/database';
import { buildVersionGlobalFields } from 'payload/versions';
import { buildVersionGlobalFields, flattenWhereToOperators } from 'payload';
import { buildSortParam } from './queries/buildSortParam.js';

@@ -4,0 +3,0 @@ import sanitizeInternalFields from './utilities/sanitizeInternalFields.js';

@@ -1,3 +0,3 @@

import type { FindOne } from 'payload/database';
import type { FindOne } from 'payload';
export declare const findOne: FindOne;
//# sourceMappingURL=findOne.d.ts.map

@@ -1,3 +0,3 @@

import type { FindVersions } from 'payload/database';
import type { FindVersions } from 'payload';
export declare const findVersions: FindVersions;
//# sourceMappingURL=findVersions.d.ts.map

@@ -1,2 +0,2 @@

import { flattenWhereToOperators } from 'payload/database';
import { flattenWhereToOperators } from 'payload';
import { buildSortParam } from './queries/buildSortParam.js';

@@ -3,0 +3,0 @@ import sanitizeInternalFields from './utilities/sanitizeInternalFields.js';

@@ -1,30 +0,5 @@

/// <reference types="mongoose/types/aggregate.js" />
/// <reference types="mongoose/types/callback.js" />
/// <reference types="mongoose/types/collection.js" />
/// <reference types="mongoose/types/connection.js" />
/// <reference types="mongoose/types/cursor.js" />
/// <reference types="mongoose/types/document.js" />
/// <reference types="mongoose/types/error.js" />
/// <reference types="mongoose/types/expressions.js" />
/// <reference types="mongoose/types/helpers.js" />
/// <reference types="mongoose/types/middlewares.js" />
/// <reference types="mongoose/types/indexes.js" />
/// <reference types="mongoose/types/models.js" />
/// <reference types="mongoose/types/mongooseoptions.js" />
/// <reference types="mongoose/types/pipelinestage.js" />
/// <reference types="mongoose/types/populate.js" />
/// <reference types="mongoose/types/query.js" />
/// <reference types="mongoose/types/schemaoptions.js" />
/// <reference types="mongoose/types/schematypes.js" />
/// <reference types="mongoose/types/session.js" />
/// <reference types="mongoose/types/types.js" />
/// <reference types="mongoose/types/utility.js" />
/// <reference types="mongoose/types/validation.js" />
/// <reference types="mongoose/types/virtuals.js" />
/// <reference types="mongoose/types/inferschematype.js" />
/// <reference types="mongoose-paginate-v2" />
import type { TransactionOptions } from 'mongodb';
import type { MongoMemoryReplSet } from 'mongodb-memory-server';
import type { ClientSession, ConnectOptions, Connection } from 'mongoose';
import type { BaseDatabaseAdapter, DatabaseAdapterObj } from 'payload/database';
import type { BaseDatabaseAdapter, DatabaseAdapterObj } from 'payload';
import type { CollectionModel, GlobalModel } from './types.js';

@@ -31,0 +6,0 @@ export type { MigrateDownArgs, MigrateUpArgs } from './types.js';

import fs from 'fs';
import mongoose from 'mongoose';
import path from 'path';
import { createDatabaseAdapter } from 'payload/database';
import { createDatabaseAdapter } from 'payload';
import { connect } from './connect.js';

@@ -6,0 +6,0 @@ import { count } from './count.js';

@@ -1,3 +0,3 @@

import type { Init } from 'payload/database';
import type { Init } from 'payload';
export declare const init: Init;
//# sourceMappingURL=init.d.ts.map
/* eslint-disable no-param-reassign */ import mongoose from 'mongoose';
import paginate from 'mongoose-paginate-v2';
import { buildVersionCollectionFields, buildVersionGlobalFields } from 'payload/versions';
import { buildVersionCollectionFields, buildVersionGlobalFields } from 'payload';
import buildCollectionSchema from './models/buildCollectionSchema.js';

@@ -5,0 +5,0 @@ import { buildGlobalModel } from './models/buildGlobalModel.js';

@@ -1,2 +0,2 @@

import { commitTransaction, initTransaction, killTransaction, readMigrationFiles } from 'payload/database';
import { commitTransaction, initTransaction, killTransaction, readMigrationFiles } from 'payload';
import prompts from 'prompts';

@@ -3,0 +3,0 @@ /**

@@ -1,31 +0,5 @@

/// <reference types="mongoose/types/aggregate.js" />
/// <reference types="mongoose/types/callback.js" />
/// <reference types="mongoose/types/collection.js" />
/// <reference types="mongoose/types/connection.js" />
/// <reference types="mongoose/types/cursor.js" />
/// <reference types="mongoose/types/document.js" />
/// <reference types="mongoose/types/error.js" />
/// <reference types="mongoose/types/expressions.js" />
/// <reference types="mongoose/types/helpers.js" />
/// <reference types="mongoose/types/middlewares.js" />
/// <reference types="mongoose/types/indexes.js" />
/// <reference types="mongoose/types/models.js" />
/// <reference types="mongoose/types/mongooseoptions.js" />
/// <reference types="mongoose/types/pipelinestage.js" />
/// <reference types="mongoose/types/populate.js" />
/// <reference types="mongoose/types/query.js" />
/// <reference types="mongoose/types/schemaoptions.js" />
/// <reference types="mongoose/types/schematypes.js" />
/// <reference types="mongoose/types/session.js" />
/// <reference types="mongoose/types/types.js" />
/// <reference types="mongoose/types/utility.js" />
/// <reference types="mongoose/types/validation.js" />
/// <reference types="mongoose/types/virtuals.js" />
/// <reference types="mongoose/types/inferschematype.js" />
/// <reference types="mongoose-paginate-v2" />
import type { Schema } from 'mongoose';
import type { SanitizedConfig } from 'payload/config';
import type { SanitizedCollectionConfig } from 'payload/types';
import type { SanitizedCollectionConfig, SanitizedConfig } from 'payload';
declare const buildCollectionSchema: (collection: SanitizedCollectionConfig, config: SanitizedConfig, schemaOptions?: {}) => Schema;
export default buildCollectionSchema;
//# sourceMappingURL=buildCollectionSchema.d.ts.map

@@ -1,4 +0,4 @@

import type { SanitizedConfig } from 'payload/config';
import type { SanitizedConfig } from 'payload';
import type { GlobalModel } from '../types.js';
export declare const buildGlobalModel: (config: SanitizedConfig) => GlobalModel | null;
//# sourceMappingURL=buildGlobalModel.d.ts.map

@@ -1,29 +0,3 @@

/// <reference types="mongoose/types/aggregate.js" />
/// <reference types="mongoose/types/callback.js" />
/// <reference types="mongoose/types/collection.js" />
/// <reference types="mongoose/types/connection.js" />
/// <reference types="mongoose/types/cursor.js" />
/// <reference types="mongoose/types/document.js" />
/// <reference types="mongoose/types/error.js" />
/// <reference types="mongoose/types/expressions.js" />
/// <reference types="mongoose/types/helpers.js" />
/// <reference types="mongoose/types/middlewares.js" />
/// <reference types="mongoose/types/indexes.js" />
/// <reference types="mongoose/types/models.js" />
/// <reference types="mongoose/types/mongooseoptions.js" />
/// <reference types="mongoose/types/pipelinestage.js" />
/// <reference types="mongoose/types/populate.js" />
/// <reference types="mongoose/types/query.js" />
/// <reference types="mongoose/types/schemaoptions.js" />
/// <reference types="mongoose/types/schematypes.js" />
/// <reference types="mongoose/types/session.js" />
/// <reference types="mongoose/types/types.js" />
/// <reference types="mongoose/types/utility.js" />
/// <reference types="mongoose/types/validation.js" />
/// <reference types="mongoose/types/virtuals.js" />
/// <reference types="mongoose/types/inferschematype.js" />
/// <reference types="mongoose-paginate-v2" />
import type { Schema, SchemaOptions } from 'mongoose';
import type { SanitizedConfig } from 'payload/config';
import type { Field } from 'payload/types';
import type { Field, SanitizedConfig } from 'payload';
export type BuildSchemaOptions = {

@@ -30,0 +4,0 @@ allowIDField?: boolean;

/* eslint-disable @typescript-eslint/ban-ts-comment */ /* eslint-disable class-methods-use-this */ /* eslint-disable @typescript-eslint/no-use-before-define */ import mongoose from 'mongoose';
import { fieldAffectsData, fieldIsLocalized, fieldIsPresentationalOnly, tabHasName } from 'payload/types';
import { fieldAffectsData, fieldIsLocalized, fieldIsPresentationalOnly, tabHasName } from 'payload/shared';
const formatBaseSchema = (field, buildSchemaOptions)=>{

@@ -4,0 +4,0 @@ const { disableUnique, draftsEnabled, indexSortableFields } = buildSchemaOptions;

@@ -1,3 +0,2 @@

import type { Payload } from 'payload';
import type { Field, Where } from 'payload/types';
import type { Field, Payload, Where } from 'payload';
export declare function buildAndOrConditions({ collectionSlug, fields, globalSlug, locale, payload, where, }: {

@@ -4,0 +3,0 @@ collectionSlug?: string;

@@ -1,3 +0,2 @@

import type { Payload } from 'payload';
import type { Field, Where } from 'payload/types';
import type { Field, Payload, Where } from 'payload';
type GetBuildQueryPluginArgs = {

@@ -4,0 +3,0 @@ collectionSlug?: string;

@@ -1,2 +0,2 @@

import { QueryError } from 'payload/errors';
import { QueryError } from 'payload';
import { parseParams } from './parseParams.js';

@@ -3,0 +3,0 @@ // This plugin asynchronously builds a list of Mongoose query constraints

@@ -1,3 +0,2 @@

import type { Payload } from 'payload';
import type { Field } from 'payload/types';
import type { Field, Payload } from 'payload';
type SearchParam = {

@@ -4,0 +3,0 @@ path?: string;

import ObjectIdImport from 'bson-objectid';
import mongoose from 'mongoose';
import { getLocalizedPaths } from 'payload/database';
import { validOperators } from 'payload/types';
import { getLocalizedPaths } from 'payload';
import { validOperators } from 'payload/shared';
import { operatorMap } from './operatorMap.js';

@@ -135,5 +135,7 @@ import { sanitizeQueryValue } from './sanitizeQueryValue.js';

let hasNumberIDRelation;
let multiIDCondition = '$or';
if (operatorKey === '$ne') multiIDCondition = '$and';
const result = {
value: {
$or: [
[multiIDCondition]: [
{

@@ -149,5 +151,5 @@ [path]: {

if (mongoose.Types.ObjectId.isValid(formattedValue)) {
result.value.$or.push({
result.value[multiIDCondition].push({
[path]: {
[operatorKey]: new ObjectId(formattedValue)
[operatorKey]: ObjectId(formattedValue)
}

@@ -164,3 +166,3 @@ });

});
if (hasNumberIDRelation) result.value.$or.push({
if (hasNumberIDRelation) result.value[multiIDCondition].push({
[path]: {

@@ -172,3 +174,3 @@ [operatorKey]: parseFloat(formattedValue)

}
if (result.value.$or.length > 1) {
if (result.value[multiIDCondition].length > 1) {
return result;

@@ -175,0 +177,0 @@ }

@@ -1,29 +0,3 @@

/// <reference types="mongoose/types/aggregate.js" />
/// <reference types="mongoose/types/callback.js" />
/// <reference types="mongoose/types/collection.js" />
/// <reference types="mongoose/types/connection.js" />
/// <reference types="mongoose/types/cursor.js" />
/// <reference types="mongoose/types/document.js" />
/// <reference types="mongoose/types/error.js" />
/// <reference types="mongoose/types/expressions.js" />
/// <reference types="mongoose/types/helpers.js" />
/// <reference types="mongoose/types/middlewares.js" />
/// <reference types="mongoose/types/indexes.js" />
/// <reference types="mongoose/types/models.js" />
/// <reference types="mongoose/types/mongooseoptions.js" />
/// <reference types="mongoose/types/pipelinestage.js" />
/// <reference types="mongoose/types/populate.js" />
/// <reference types="mongoose/types/query.js" />
/// <reference types="mongoose/types/schemaoptions.js" />
/// <reference types="mongoose/types/schematypes.js" />
/// <reference types="mongoose/types/session.js" />
/// <reference types="mongoose/types/types.js" />
/// <reference types="mongoose/types/utility.js" />
/// <reference types="mongoose/types/validation.js" />
/// <reference types="mongoose/types/virtuals.js" />
/// <reference types="mongoose/types/inferschematype.js" />
/// <reference types="mongoose-paginate-v2" />
import type { PaginateOptions } from 'mongoose';
import type { SanitizedConfig } from 'payload/config';
import type { Field } from 'payload/types';
import type { Field, SanitizedConfig } from 'payload';
type Args = {

@@ -41,4 +15,4 @@ config: SanitizedConfig;

export type SortDirection = 'asc' | 'desc';
export declare const buildSortParam: ({ config, fields, locale, sort, timestamps, }: Args) => PaginateOptions['sort'];
export declare const buildSortParam: ({ config, fields, locale, sort, timestamps, }: Args) => PaginateOptions["sort"];
export {};
//# sourceMappingURL=buildSortParam.d.ts.map

@@ -1,3 +0,2 @@

import type { SanitizedConfig } from 'payload/config';
import type { Field } from 'payload/types';
import type { Field, SanitizedConfig } from 'payload';
type Args = {

@@ -4,0 +3,0 @@ config: SanitizedConfig;

@@ -1,3 +0,3 @@

import { fieldAffectsData, fieldIsPresentationalOnly } from 'payload/types';
import { flattenTopLevelFields } from 'payload/utilities';
import { flattenTopLevelFields } from 'payload';
import { fieldAffectsData, fieldIsPresentationalOnly } from 'payload/shared';
export const getLocalizedSortProperty = ({ config, fields: incomingFields, locale, result: incomingResult, segments: incomingSegments })=>{

@@ -4,0 +4,0 @@ // If localization is not enabled, accept exactly

@@ -1,2 +0,2 @@

import { sanitizeConfig } from 'payload/config';
import { sanitizeConfig } from 'payload';
import { getLocalizedSortProperty } from './getLocalizedSortProperty.js';

@@ -3,0 +3,0 @@ let config;

@@ -1,4 +0,2 @@

import type { Payload } from 'payload';
import type { Where } from 'payload/types';
import type { Field } from 'payload/types';
import type { Field, Payload, Where } from 'payload';
export declare function parseParams({ collectionSlug, fields, globalSlug, locale, payload, where, }: {

@@ -5,0 +3,0 @@ collectionSlug?: string;

/* eslint-disable no-restricted-syntax */ /* eslint-disable no-await-in-loop */ import deepmerge from 'deepmerge';
import { validOperators } from 'payload/types';
import { combineMerge } from 'payload/utilities';
import { combineMerge } from 'payload';
import { validOperators } from 'payload/shared';
import { buildAndOrConditions } from './buildAndOrConditions.js';

@@ -5,0 +5,0 @@ import { buildSearchParam } from './buildSearchParams.js';

@@ -1,2 +0,2 @@

import type { Field, TabAsField } from 'payload/types';
import type { Field, TabAsField } from 'payload';
type SanitizeQueryValueArgs = {

@@ -3,0 +3,0 @@ field: Field | TabAsField;

import mongoose from 'mongoose';
import { createArrayFromCommaDelineated } from 'payload/utilities';
import { createArrayFromCommaDelineated } from 'payload';
export const sanitizeQueryValue = ({ field, hasCustomID, operator, path, val })=>{

@@ -4,0 +4,0 @@ let formattedValue = val;

@@ -1,3 +0,3 @@

import type { QueryDrafts } from 'payload/database';
import type { QueryDrafts } from 'payload';
export declare const queryDrafts: QueryDrafts;
//# sourceMappingURL=queryDrafts.d.ts.map

@@ -1,2 +0,2 @@

import { combineQueries, flattenWhereToOperators } from 'payload/database';
import { combineQueries, flattenWhereToOperators } from 'payload';
import { buildSortParam } from './queries/buildSortParam.js';

@@ -3,0 +3,0 @@ import sanitizeInternalFields from './utilities/sanitizeInternalFields.js';

@@ -1,3 +0,3 @@

import type { BeginTransaction } from 'payload/database';
import type { BeginTransaction } from 'payload';
export declare const beginTransaction: BeginTransaction;
//# sourceMappingURL=beginTransaction.d.ts.map

@@ -1,2 +0,2 @@

import { APIError } from 'payload/errors';
import { APIError } from 'payload';
import { v4 as uuid } from 'uuid';

@@ -3,0 +3,0 @@ export const beginTransaction = async function beginTransaction(options) {

@@ -1,3 +0,3 @@

import type { CommitTransaction } from 'payload/database';
import type { CommitTransaction } from 'payload';
export declare const commitTransaction: CommitTransaction;
//# sourceMappingURL=commitTransaction.d.ts.map

@@ -1,3 +0,3 @@

import type { RollbackTransaction } from 'payload/database';
import type { RollbackTransaction } from 'payload';
export declare const rollbackTransaction: RollbackTransaction;
//# sourceMappingURL=rollbackTransaction.d.ts.map

@@ -1,30 +0,3 @@

/// <reference types="mongoose/types/aggregate.js" />
/// <reference types="mongoose/types/callback.js" />
/// <reference types="mongoose/types/collection.js" />
/// <reference types="mongoose/types/connection.js" />
/// <reference types="mongoose/types/cursor.js" />
/// <reference types="mongoose/types/document.js" />
/// <reference types="mongoose/types/error.js" />
/// <reference types="mongoose/types/expressions.js" />
/// <reference types="mongoose/types/helpers.js" />
/// <reference types="mongoose/types/middlewares.js" />
/// <reference types="mongoose/types/indexes.js" />
/// <reference types="mongoose/types/models.js" />
/// <reference types="mongoose/types/mongooseoptions.js" />
/// <reference types="mongoose/types/pipelinestage.js" />
/// <reference types="mongoose/types/populate.js" />
/// <reference types="mongoose/types/query.js" />
/// <reference types="mongoose/types/schemaoptions.js" />
/// <reference types="mongoose/types/schematypes.js" />
/// <reference types="mongoose/types/session.js" />
/// <reference types="mongoose/types/types.js" />
/// <reference types="mongoose/types/utility.js" />
/// <reference types="mongoose/types/validation.js" />
/// <reference types="mongoose/types/virtuals.js" />
/// <reference types="mongoose/types/inferschematype.js" />
/// <reference types="mongoose-paginate-v2" />
import type { IndexDefinition, IndexOptions, Model, PaginateModel, SchemaOptions } from 'mongoose';
import type { Payload } from 'payload';
import type { SanitizedConfig } from 'payload/config';
import type { ArrayField, BlockField, CheckboxField, CodeField, CollapsibleField, DateField, EmailField, Field, GroupField, JSONField, NumberField, PointField, RadioField, RelationshipField, RichTextField, RowField, SelectField, TabsField, TextField, TextareaField, UploadField } from 'payload/types';
import type { ArrayField, BlockField, CheckboxField, CodeField, CollapsibleField, DateField, EmailField, Field, GroupField, JSONField, NumberField, Payload, PointField, RadioField, RelationshipField, RichTextField, RowField, SanitizedConfig, SelectField, TabsField, TextField, TextareaField, UploadField } from 'payload';
import type { BuildQueryArgs } from './queries/buildQuery.js';

@@ -31,0 +4,0 @@ export interface CollectionModel extends Model<any>, PaginateModel<any> {

@@ -1,3 +0,3 @@

import type { UpdateGlobal } from 'payload/database';
import type { UpdateGlobal } from 'payload';
export declare const updateGlobal: UpdateGlobal;
//# sourceMappingURL=updateGlobal.d.ts.map

@@ -1,5 +0,4 @@

import type { UpdateGlobalVersionArgs } from 'payload/database';
import type { TypeWithID } from 'payload/types';
import type { TypeWithID, UpdateGlobalVersionArgs } from 'payload';
import type { MongooseAdapter } from './index.js';
export declare function updateGlobalVersion<T extends TypeWithID>(this: MongooseAdapter, { id, global, locale, req, versionData, where, }: UpdateGlobalVersionArgs<T>): Promise<any>;
//# sourceMappingURL=updateGlobalVersion.d.ts.map

@@ -1,3 +0,3 @@

import type { UpdateOne } from 'payload/database';
import type { UpdateOne } from 'payload';
export declare const updateOne: UpdateOne;
//# sourceMappingURL=updateOne.d.ts.map

@@ -1,2 +0,2 @@

import handleError from './utilities/handleError.js';
import { handleError } from './utilities/handleError.js';
import sanitizeInternalFields from './utilities/sanitizeInternalFields.js';

@@ -25,3 +25,7 @@ import { withSession } from './withSession.js';

} catch (error) {
handleError(error, req);
handleError({
collection,
error,
req
});
}

@@ -28,0 +32,0 @@ result = JSON.parse(JSON.stringify(result));

@@ -1,3 +0,3 @@

import type { UpdateVersion } from 'payload/database';
import type { UpdateVersion } from 'payload';
export declare const updateVersion: UpdateVersion;
//# sourceMappingURL=updateVersion.d.ts.map

@@ -1,2 +0,2 @@

import type { DBIdentifierName } from 'payload/database';
import type { DBIdentifierName } from 'payload';
type Args = {

@@ -3,0 +3,0 @@ config: {

@@ -1,3 +0,7 @@

declare const handleError: (error: any, req: any) => never;
export default handleError;
export declare const handleError: ({ collection, error, global, req, }: {
collection?: string;
error: any;
global?: string;
req: any;
}) => never;
//# sourceMappingURL=handleError.d.ts.map
import httpStatus from 'http-status';
import { APIError, ValidationError } from 'payload/errors';
const handleError = (error, req)=>{
import { APIError, ValidationError } from 'payload';
export const handleError = ({ collection, error, global, req })=>{
// Handle uniqueness error from MongoDB
if (error.code === 11000 && error.keyValue) {
throw new ValidationError([
{
field: Object.keys(error.keyValue)[0],
message: req.t('error:valueMustBeUnique')
}
], req.t);
throw new ValidationError({
collection,
errors: [
{
field: Object.keys(error.keyValue)[0],
message: req.t('error:valueMustBeUnique')
}
],
global
}, req.t);
} else if (error.code === 11000) {

@@ -18,4 +22,3 @@ throw new APIError(req.t('error:valueMustBeUnique'), httpStatus.BAD_REQUEST);

};
export default handleError;
//# sourceMappingURL=handleError.js.map

@@ -1,26 +0,1 @@

/// <reference types="mongoose/types/aggregate.js" />
/// <reference types="mongoose/types/callback.js" />
/// <reference types="mongoose/types/collection.js" />
/// <reference types="mongoose/types/connection.js" />
/// <reference types="mongoose/types/cursor.js" />
/// <reference types="mongoose/types/document.js" />
/// <reference types="mongoose/types/error.js" />
/// <reference types="mongoose/types/expressions.js" />
/// <reference types="mongoose/types/helpers.js" />
/// <reference types="mongoose/types/middlewares.js" />
/// <reference types="mongoose/types/indexes.js" />
/// <reference types="mongoose/types/models.js" />
/// <reference types="mongoose/types/mongooseoptions.js" />
/// <reference types="mongoose/types/pipelinestage.js" />
/// <reference types="mongoose/types/populate.js" />
/// <reference types="mongoose/types/query.js" />
/// <reference types="mongoose/types/schemaoptions.js" />
/// <reference types="mongoose/types/schematypes.js" />
/// <reference types="mongoose/types/session.js" />
/// <reference types="mongoose/types/types.js" />
/// <reference types="mongoose/types/utility.js" />
/// <reference types="mongoose/types/validation.js" />
/// <reference types="mongoose/types/virtuals.js" />
/// <reference types="mongoose/types/inferschematype.js" />
/// <reference types="mongoose-paginate-v2" />
import type { ClientSession } from 'mongoose';

@@ -27,0 +2,0 @@ import type { MongooseAdapter } from './index.js';

{
"name": "@payloadcms/db-mongodb",
"version": "3.0.0-canary.f6e77b8",
"version": "3.0.0-canary.f83d96a",
"description": "The officially supported MongoDB database adapter for Payload",

@@ -17,4 +17,4 @@ "homepage": "https://payloadcms.com",

"import": "./dist/index.js",
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}

@@ -32,3 +32,2 @@ },

"deepmerge": "4.3.1",
"get-port": "5.1.1",
"http-status": "1.6.2",

@@ -38,3 +37,3 @@ "mongoose": "6.12.3",

"prompts": "2.4.2",
"uuid": "9.0.0"
"uuid": "10.0.0"
},

@@ -46,10 +45,10 @@ "devDependencies": {

"@payloadcms/eslint-config": "1.1.1",
"payload": "3.0.0-canary.f6e77b8"
"payload": "3.0.0-canary.f83d96a"
},
"peerDependencies": {
"payload": "3.0.0-canary.f6e77b8"
"payload": "3.0.0-canary.f83d96a"
},
"scripts": {
"build": "pnpm build:swc && pnpm build:types",
"build:swc": "swc ./src -d ./dist --config-file .swcrc-build",
"build": "pnpm build:types && pnpm build:swc",
"build:swc": "swc ./src -d ./dist --config-file .swcrc-build --strip-leading-paths",
"build:types": "tsc --emitDeclarationOnly --outDir dist",

@@ -56,0 +55,0 @@ "clean": "rimraf {dist,*.tsbuildinfo}"

@@ -17,3 +17,3 @@ # Payload MongoDB Adapter

```ts
import { buildConfig } from 'payload/config'
import { buildConfig } from 'payload'
import { mongooseAdapter } from '@payloadcms/db-mongodb'

@@ -20,0 +20,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc