chore: undo lint changes to db-* and drizzle
This commit is contained in:
@@ -29,9 +29,7 @@ export const connect: Connect = async function connect(
|
||||
useFacet: undefined,
|
||||
}
|
||||
|
||||
if (hotReload) {
|
||||
connectionOptions.autoIndex = false
|
||||
}
|
||||
if (hotReload) connectionOptions.autoIndex = false
|
||||
|
||||
try {
|
||||
this.connection = (await mongoose.connect(urlToConnect, connectionOptions)).connection
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { CollationOptions, TransactionOptions } from 'mongodb'
|
||||
import type { MongoMemoryReplSet } from 'mongodb-memory-server'
|
||||
import type { ClientSession, Connection, ConnectOptions } from 'mongoose'
|
||||
import type { ClientSession, ConnectOptions, Connection } from 'mongoose'
|
||||
import type { BaseDatabaseAdapter, DatabaseAdapterObj, Payload } from 'payload'
|
||||
|
||||
import fs from 'fs'
|
||||
@@ -83,7 +83,7 @@ export interface Args {
|
||||
name: string
|
||||
up: (args: MigrateUpArgs) => Promise<void>
|
||||
}[]
|
||||
transactionOptions?: false | TransactionOptions
|
||||
transactionOptions?: TransactionOptions | false
|
||||
/** The URL to connect to MongoDB or false to start payload and prevent connecting */
|
||||
url: false | string
|
||||
}
|
||||
@@ -150,8 +150,8 @@ export function mongooseAdapter({
|
||||
// Mongoose-specific
|
||||
autoPluralization,
|
||||
collections: {},
|
||||
connection: undefined,
|
||||
connectOptions: connectOptions || {},
|
||||
connection: undefined,
|
||||
count,
|
||||
disableIndexHints,
|
||||
globals: undefined,
|
||||
@@ -221,9 +221,7 @@ function findMigrationDir(migrationDir?: string): string {
|
||||
const relativeMigrations = path.resolve(cwd, 'migrations')
|
||||
|
||||
// Use arg if provided
|
||||
if (migrationDir) {
|
||||
return migrationDir
|
||||
}
|
||||
if (migrationDir) return migrationDir
|
||||
|
||||
// Check other common locations
|
||||
if (fs.existsSync(srcDir)) {
|
||||
|
||||
@@ -24,8 +24,8 @@ import type {
|
||||
SelectField,
|
||||
Tab,
|
||||
TabsField,
|
||||
TextareaField,
|
||||
TextField,
|
||||
TextareaField,
|
||||
UploadField,
|
||||
} from 'payload'
|
||||
|
||||
@@ -92,7 +92,7 @@ const formatBaseSchema = (field: FieldAffectingData, buildSchemaOptions: BuildSc
|
||||
const localizeSchema = (
|
||||
entity: NonPresentationalField | Tab,
|
||||
schema,
|
||||
localization: false | SanitizedLocalizationConfig,
|
||||
localization: SanitizedLocalizationConfig | false,
|
||||
) => {
|
||||
if (fieldIsLocalized(entity) && localization && Array.isArray(localization.locales)) {
|
||||
return {
|
||||
@@ -384,9 +384,7 @@ const fieldToSchemaMap: Record<string, FieldSchemaGenerator> = {
|
||||
...formatBaseSchema(field, buildSchemaOptions),
|
||||
type: String,
|
||||
enum: field.options.map((option) => {
|
||||
if (typeof option === 'object') {
|
||||
return option.value
|
||||
}
|
||||
if (typeof option === 'object') return option.value
|
||||
return option
|
||||
}),
|
||||
}
|
||||
@@ -513,9 +511,7 @@ const fieldToSchemaMap: Record<string, FieldSchemaGenerator> = {
|
||||
...formatBaseSchema(field, buildSchemaOptions),
|
||||
type: String,
|
||||
enum: field.options.map((option) => {
|
||||
if (typeof option === 'object') {
|
||||
return option.value
|
||||
}
|
||||
if (typeof option === 'object') return option.value
|
||||
return option
|
||||
}),
|
||||
}
|
||||
|
||||
@@ -48,9 +48,7 @@ export async function buildSearchParam({
|
||||
}): Promise<SearchParam> {
|
||||
// Replace GraphQL nested field double underscore formatting
|
||||
let sanitizedPath = incomingPath.replace(/__/g, '.')
|
||||
if (sanitizedPath === 'id') {
|
||||
sanitizedPath = '_id'
|
||||
}
|
||||
if (sanitizedPath === 'id') sanitizedPath = '_id'
|
||||
|
||||
let paths: PathToQuery[] = []
|
||||
|
||||
@@ -101,9 +99,7 @@ export async function buildSearchParam({
|
||||
val,
|
||||
})
|
||||
|
||||
if (rawQuery) {
|
||||
return { value: rawQuery }
|
||||
}
|
||||
if (rawQuery) return { value: rawQuery }
|
||||
|
||||
// If there are multiple collections to search through,
|
||||
// Recursively build up a list of query constraints
|
||||
@@ -194,9 +190,7 @@ export async function buildSearchParam({
|
||||
if (field.type === 'relationship' || field.type === 'upload') {
|
||||
let hasNumberIDRelation
|
||||
let multiIDCondition = '$or'
|
||||
if (operatorKey === '$ne') {
|
||||
multiIDCondition = '$and'
|
||||
}
|
||||
if (operatorKey === '$ne') multiIDCondition = '$and'
|
||||
|
||||
const result = {
|
||||
value: {
|
||||
@@ -221,11 +215,10 @@ export async function buildSearchParam({
|
||||
},
|
||||
)
|
||||
|
||||
if (hasNumberIDRelation) {
|
||||
if (hasNumberIDRelation)
|
||||
result.value[multiIDCondition].push({
|
||||
[path]: { [operatorKey]: parseFloat(formattedValue) },
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,9 +43,7 @@ export async function parseParams({
|
||||
payload,
|
||||
where: condition,
|
||||
})
|
||||
if (builtConditions.length > 0) {
|
||||
result[conditionOperator] = builtConditions
|
||||
}
|
||||
if (builtConditions.length > 0) result[conditionOperator] = builtConditions
|
||||
} else {
|
||||
// It's a path - and there can be multiple comparisons on a single path.
|
||||
// For example - title like 'test' and title not equal to 'tester'
|
||||
|
||||
@@ -46,12 +46,8 @@ export const sanitizeQueryValue = ({
|
||||
|
||||
// Cast incoming values as proper searchable types
|
||||
if (field.type === 'checkbox' && typeof val === 'string') {
|
||||
if (val.toLowerCase() === 'true') {
|
||||
formattedValue = true
|
||||
}
|
||||
if (val.toLowerCase() === 'false') {
|
||||
formattedValue = false
|
||||
}
|
||||
if (val.toLowerCase() === 'true') formattedValue = true
|
||||
if (val.toLowerCase() === 'false') formattedValue = false
|
||||
}
|
||||
|
||||
if (['all', 'in', 'not_in'].includes(operator) && typeof formattedValue === 'string') {
|
||||
@@ -99,14 +95,11 @@ export const sanitizeQueryValue = ({
|
||||
if (operator === 'in' && Array.isArray(formattedValue)) {
|
||||
formattedValue = formattedValue.reduce((formattedValues, inVal) => {
|
||||
const newValues = [inVal]
|
||||
if (mongoose.Types.ObjectId.isValid(inVal)) {
|
||||
if (mongoose.Types.ObjectId.isValid(inVal))
|
||||
newValues.push(new mongoose.Types.ObjectId(inVal))
|
||||
}
|
||||
|
||||
const parsedNumber = parseFloat(inVal)
|
||||
if (!Number.isNaN(parsedNumber)) {
|
||||
newValues.push(parsedNumber)
|
||||
}
|
||||
if (!Number.isNaN(parsedNumber)) newValues.push(parsedNumber)
|
||||
|
||||
return [...formattedValues, ...newValues]
|
||||
}, [])
|
||||
@@ -136,12 +129,8 @@ export const sanitizeQueryValue = ({
|
||||
$geometry: { type: 'Point', coordinates: [parseFloat(lng), parseFloat(lat)] },
|
||||
}
|
||||
|
||||
if (maxDistance) {
|
||||
formattedValue.$maxDistance = parseFloat(maxDistance)
|
||||
}
|
||||
if (minDistance) {
|
||||
formattedValue.$minDistance = parseFloat(minDistance)
|
||||
}
|
||||
if (maxDistance) formattedValue.$maxDistance = parseFloat(maxDistance)
|
||||
if (minDistance) formattedValue.$minDistance = parseFloat(minDistance)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import type { CommitTransaction } from 'payload'
|
||||
|
||||
export const commitTransaction: CommitTransaction = async function commitTransaction(id) {
|
||||
if (id instanceof Promise) {
|
||||
return
|
||||
}
|
||||
if (id instanceof Promise) return
|
||||
|
||||
if (!this.sessions[id]?.inTransaction()) {
|
||||
return
|
||||
|
||||
@@ -20,8 +20,8 @@ import type {
|
||||
SanitizedConfig,
|
||||
SelectField,
|
||||
TabsField,
|
||||
TextareaField,
|
||||
TextField,
|
||||
TextareaField,
|
||||
UploadField,
|
||||
} from 'payload'
|
||||
|
||||
|
||||
@@ -35,9 +35,7 @@ export const getDBName = ({
|
||||
result = name ?? slug
|
||||
}
|
||||
|
||||
if (versions) {
|
||||
result = `_${result}_versions`
|
||||
}
|
||||
if (versions) result = `_${result}_versions`
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -17,7 +17,5 @@ export async function withSession(
|
||||
transactionID = await req.transactionID
|
||||
}
|
||||
|
||||
if (req) {
|
||||
return db.sessions[transactionID] ? { session: db.sessions[transactionID] } : {}
|
||||
}
|
||||
if (req) return db.sessions[transactionID] ? { session: db.sessions[transactionID] } : {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user