Skip to content

Commit 75cc5ee

Browse files
refactor(deleteReferences): Remove restriction for subcollection
1 parent c4a9c74 commit 75cc5ee

File tree

2 files changed

+1
-18
lines changed

2 files changed

+1
-18
lines changed

src/common.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,6 @@ export function isConfig(arg: Rule | Config): arg is Config {
1818
return (arg as Config).config !== undefined;
1919
}
2020

21-
export function isSubCollection(collection: string): boolean {
22-
const filteredCollections = collection.split('/').filter(c => c.length > 0);
23-
const numCollections = filteredCollections.length;
24-
// Return false is equal to 1 or an even number
25-
return numCollections !== 1 && numCollections % 2 === 1;
26-
}
27-
2821
enum Key {
2922
Primary = '{(.*?)}',
3023
Foreign = '([$][^/]*|$)',

src/rules/deleteReferences.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import {
2-
Config,
3-
Rule,
4-
replaceReferencesWith,
5-
getPrimaryKey,
6-
isSubCollection,
7-
} from '../common';
1+
import { Config, Rule, replaceReferencesWith, getPrimaryKey } from '../common';
82

93
export interface DeleteReferencesRule extends Rule {
104
source: {
@@ -80,10 +74,6 @@ export function integrifyDeleteReferences(
8074
throw new Error(
8175
`integrify: missing foreign key or set deleteAll to true`
8276
);
83-
} else if (target.deleteAll && !isSubCollection(target.collection)) {
84-
throw new Error(
85-
`integrify: [${target.collection}] is an invalid sub-collection`
86-
);
8777
}
8878

8979
// Replace the context.params in the target collection

0 commit comments

Comments
 (0)