Skip to content

Commit

Permalink
fixed Process model
Browse files Browse the repository at this point in the history
  • Loading branch information
andrefs committed Oct 18, 2023
1 parent 82a1eab commit 4f39647
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
13 changes: 9 additions & 4 deletions src/models/Process.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Types } from 'mongoose';
import { Types, Document } from 'mongoose';
import { Resource } from './Resource';
import { Triple, TripleClass } from './Triple';
import { humanize } from 'humanize-digest';
import { Domain } from './Domain';
import { PathClass, Path, PathDocument } from './Path';
import { Path, PathDocument } from './Path';
import { ProcessTriple } from './ProcessTriple';
import {
prop,
Expand Down Expand Up @@ -52,6 +52,9 @@ class ParamsClass {
}

class ProcessClass {
createdAt!: Date;
updatedAt!: Date;

@prop({ required: true, index: true, unique: true })
public pid!: string;

Expand Down Expand Up @@ -131,7 +134,7 @@ class ProcessClass {
return paths;
}

public async extendPathsWithExistingTriples(paths: PathClass[]) {
public async extendPathsWithExistingTriples(paths: PathDocument[]) {
for (const path of paths) {
const newPathObjs = [];
const toDelete = new Set();
Expand Down Expand Up @@ -363,4 +366,6 @@ const Process = getModelForClass(ProcessClass, {
schemaOptions: { timestamps: true },
});

export { Process, ProcessClass };
type ProcessDocument = ProcessClass & Document;

export { Process, ProcessClass, ProcessDocument };
8 changes: 6 additions & 2 deletions src/models/Resource.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Types } from 'mongoose';
import { Types, Document } from 'mongoose';
import { urlValidator, WorkerError } from '@derzis/common';
import { Domain } from '@derzis/models';
import { Path, PathDocument } from './Path';
Expand All @@ -22,6 +22,9 @@ class CrawlId {
}

class ResourceClass {
createdAt!: Date;
updatedAt!: Date;

@prop({ required: true, validate: urlValidator })
public url!: string;

Expand Down Expand Up @@ -220,5 +223,6 @@ class ResourceClass {
const Resource = getModelForClass(ResourceClass, {
schemaOptions: { timestamps: true },
});
type ResourceDocument = ResourceClass & Document;

export { Resource, ResourceClass };
export { Resource, ResourceClass, ResourceDocument };

0 comments on commit 4f39647

Please sign in to comment.