### What? Adds full support for the point field to Postgres and Vercel Postgres adapters through the Postgis extension. Fully the same API as with MongoDB, including support for `near`, `within` and `intersects` operators. Additionally, exposes to adapter args: * `tablesFilter`https://orm.drizzle.team/docs/drizzle-kit-push#including-tables-schemas-and-extensions. * `extensions` list of extensions to create, for example `['vector', 'pg_search']`, `postgis` is created automatically if there's any point field ### Why? It's essential to support that field type, especially if the postgres adapter should be out of beta on 3.0 stable. ### How? * Bumps `drizzle-orm` to `0.36.1` and `drizzle-kit` to `0.28.0` as we need this change https://github.com/drizzle-team/drizzle-orm/pull/3141 * Uses its functions to achieve querying functionality, for example the `near` operator works through `ST_DWithin` or `intersects` through `ST_Intersects`. * Removes MongoDB condition from all point field tests, but keeps for SQLite Resolves these discussions: https://github.com/payloadcms/payload/discussions/8996 https://github.com/payloadcms/payload/discussions/8644
78 lines
2.0 KiB
TypeScript
78 lines
2.0 KiB
TypeScript
import { lexicalEditor } from '@payloadcms/richtext-lexical'
|
|
import { fileURLToPath } from 'node:url'
|
|
import path from 'path'
|
|
|
|
import { buildConfigWithDefaults } from '../buildConfigWithDefaults.js'
|
|
import { devUser } from '../credentials.js'
|
|
import { DeepPostsCollection } from './collections/DeepPosts/index.js'
|
|
import { LocalizedPostsCollection } from './collections/LocalizedPosts/index.js'
|
|
import { Pages } from './collections/Pages/index.js'
|
|
import { Points } from './collections/Points/index.js'
|
|
import { PostsCollection } from './collections/Posts/index.js'
|
|
import { VersionedPostsCollection } from './collections/VersionedPosts/index.js'
|
|
|
|
const filename = fileURLToPath(import.meta.url)
|
|
const dirname = path.dirname(filename)
|
|
|
|
export default buildConfigWithDefaults({
|
|
// ...extend config here
|
|
collections: [
|
|
PostsCollection,
|
|
LocalizedPostsCollection,
|
|
VersionedPostsCollection,
|
|
DeepPostsCollection,
|
|
Pages,
|
|
Points,
|
|
],
|
|
globals: [
|
|
{
|
|
slug: 'global-post',
|
|
fields: [
|
|
{
|
|
name: 'text',
|
|
type: 'text',
|
|
},
|
|
{
|
|
name: 'number',
|
|
type: 'number',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
admin: {
|
|
importMap: {
|
|
baseDir: path.resolve(dirname),
|
|
},
|
|
},
|
|
localization: {
|
|
locales: ['en', 'de'],
|
|
defaultLocale: 'en',
|
|
},
|
|
editor: lexicalEditor({
|
|
features: ({ defaultFeatures }) => [...defaultFeatures],
|
|
}),
|
|
cors: ['http://localhost:3000', 'http://localhost:3001'],
|
|
onInit: async (payload) => {
|
|
await payload.create({
|
|
collection: 'users',
|
|
data: {
|
|
email: devUser.email,
|
|
password: devUser.password,
|
|
},
|
|
})
|
|
|
|
// // Create image
|
|
// const imageFilePath = path.resolve(dirname, '../uploads/image.png')
|
|
// const imageFile = await getFileByPath(imageFilePath)
|
|
|
|
// await payload.create({
|
|
// collection: 'media',
|
|
// data: {},
|
|
// file: imageFile,
|
|
// })
|
|
},
|
|
typescript: {
|
|
outputFile: path.resolve(dirname, 'payload-types.ts'),
|
|
},
|
|
})
|