Migrate atlasId -> collectionId

This commit is contained in:
Tom Moor
2018-08-07 23:23:26 -07:00
parent f49c495a9a
commit 18cfe26e83
11 changed files with 50 additions and 24 deletions

View File

@ -19,7 +19,7 @@ router.post('documents.list', auth(), pagination(), async ctx => {
const user = ctx.state.user;
let where = { teamId: user.teamId };
if (collection) where = { ...where, atlasId: collection };
if (collection) where = { ...where, collectionId: collection };
const starredScope = { method: ['withStarred', user.id] };
const documents = await Document.scope('defaultScope', starredScope).findAll({
@ -49,7 +49,7 @@ router.post('documents.pinned', auth(), pagination(), async ctx => {
const documents = await Document.scope('defaultScope', starredScope).findAll({
where: {
teamId: user.teamId,
atlasId: collection,
collectionId: collection,
pinnedById: {
// $FlowFixMe
[Op.ne]: null,
@ -329,7 +329,7 @@ router.post('documents.create', auth(), async ctx => {
parentDocumentObj = await Document.findOne({
where: {
id: parentDocument,
atlasId: collection.id,
collectionId: collection.id,
},
});
authorize(user, 'read', parentDocumentObj);
@ -337,7 +337,7 @@ router.post('documents.create', auth(), async ctx => {
let document = await Document.create({
parentDocumentId: parentDocumentObj.id,
atlasId: collection.id,
collectionId: collection.id,
teamId: user.teamId,
userId: user.id,
lastModifiedById: user.id,

View File

@ -155,7 +155,10 @@ describe('#documents.list', async () => {
it('should allow filtering by collection', async () => {
const { user, document } = await seed();
const res = await server.post('/api/documents.list', {
body: { token: user.getJwtToken(), collection: document.atlasId },
body: {
token: user.getJwtToken(),
collection: document.collectionId,
},
});
const body = await res.json();