chore: Remove all usage of collection.type (#1445)
* chore: Remove all usage of collection.type * migration: Remove type column
This commit is contained in:
@@ -30,7 +30,7 @@ const { authorize } = policy;
|
||||
const router = new Router();
|
||||
|
||||
router.post("collections.create", auth(), async (ctx) => {
|
||||
const { name, color, description, icon, type } = ctx.body;
|
||||
const { name, color, description, icon } = ctx.body;
|
||||
const isPrivate = ctx.body.private;
|
||||
ctx.assertPresent(name, "name is required");
|
||||
|
||||
@@ -46,7 +46,6 @@ router.post("collections.create", auth(), async (ctx) => {
|
||||
description,
|
||||
icon,
|
||||
color,
|
||||
type: type || "atlas",
|
||||
teamId: user.teamId,
|
||||
creatorId: user.id,
|
||||
private: isPrivate,
|
||||
|
||||
@@ -1062,7 +1062,6 @@ describe("#collections.delete", () => {
|
||||
urlId: "blah",
|
||||
teamId: user.teamId,
|
||||
creatorId: user.id,
|
||||
type: "atlas",
|
||||
});
|
||||
|
||||
const res = await server.post("/api/collections.delete", {
|
||||
|
||||
@@ -718,7 +718,7 @@ router.post("documents.create", auth(), async (ctx) => {
|
||||
authorize(user, "publish", collection);
|
||||
|
||||
let parentDocument;
|
||||
if (parentDocumentId && collection.type === "atlas") {
|
||||
if (parentDocumentId) {
|
||||
parentDocument = await Document.findOne({
|
||||
where: {
|
||||
id: parentDocumentId,
|
||||
@@ -938,13 +938,6 @@ router.post("documents.move", auth(), async (ctx) => {
|
||||
const document = await Document.findByPk(id, { userId: user.id });
|
||||
authorize(user, "move", document);
|
||||
|
||||
const { collection } = document;
|
||||
if (collection.type !== "atlas" && parentDocumentId) {
|
||||
throw new InvalidRequestError(
|
||||
"Document cannot be nested in this collection type"
|
||||
);
|
||||
}
|
||||
|
||||
if (parentDocumentId) {
|
||||
const parent = await Document.findByPk(parentDocumentId, {
|
||||
userId: user.id,
|
||||
|
||||
Reference in New Issue
Block a user