// Import from server-only api
import { getModel } from "@factor/api/server"
// Get a user based on their userId
const getUser = async (_id) => {
return await await getModel("user").findOne({ _id })
}
// Endpoint to create an attachment
const createAttachment = async (data) => {
const attachmentModel = getModel("attachment")
const attachment = new attachmentModel(data)
return await attachment.save()
}
import { addPostType, ObjectId } from "@factor/api"
addPostType({
schemaDefinition: {
foo: String,
bar: Buffer,
baz: Number,
buz: {ref: "anotherPostType", type: ObjectId}
},
schemaMiddleware: Schema => {
Schema.pre('save', function(){
// add middleware
})
}
schemaPopulated: {
buz: "any" // "any" | "list" | "single"
}
schemaOptions: {}
// ...other post type options
})
// Add the schema to factor
addPostSchema(mySchema)
3. Markdown Image Loader link need to be fixed, he is going to the wrong url
<a href="./https://github.com/lucsorel/markdown-image-loader">Markdown Image Loader</a>
you added ./ at the first, I think you mean This
<a href="https://github.com/lucsorel/markdown-image-loader">Markdown Image Loader</a>
at https://factor.dev/docs/markdown#reading-markdown-files
maybe I am wrong I just want to help, thanks for the greate work ;)
It's a greate documentation, When I was reading the Docs I noticed Three things.
1. you writed two times
await await
in https://factor.dev/docs/database#query-directly-with-mongoose-models2. you forget a to declare addPostSchema in https://factor.dev/docs/post-types#schema-definition
3. Markdown Image Loader link need to be fixed, he is going to the wrong url
<a href="./https://github.com/lucsorel/markdown-image-loader">Markdown Image Loader</a>
you added./
at the first, I think you mean This<a href="https://github.com/lucsorel/markdown-image-loader">Markdown Image Loader</a>
at https://factor.dev/docs/markdown#reading-markdown-filesmaybe I am wrong I just want to help, thanks for the greate work ;)