Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/collections/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ export type UpdateObject<T> = {
/** The ID of the object to be updated */
id: string;
/** The properties of the object to be updated */
properties?: NonReferenceInputs<T>;
properties?: Partial<NonReferenceInputs<T>>;
/** The references of the object to be updated */
references?: ReferenceInputs<T>;
references?: Partial<ReferenceInputs<T>>;
//* The vector(s) to update in the object */
vectors?: number[] | Vectors;
};
Expand Down Expand Up @@ -170,6 +170,13 @@ const addContext = <B extends IBuilder>(
return builder;
};

type ParseObject<T> = {
id?: string;
properties?: Partial<NonReferenceInputs<T>>;
references?: Partial<ReferenceInputs<T>>;
vectors?: number[] | Vectors;
};

const data = <T>(
connection: Connection,
name: string,
Expand All @@ -180,7 +187,7 @@ const data = <T>(
const objectsPath = new ObjectsPath(dbVersionSupport);
const referencesPath = new ReferencesPath(dbVersionSupport);

const parseObject = async (object?: InsertObject<any>): Promise<WeaviateObject<T>> => {
const parseObject = async (object?: ParseObject<any>): Promise<WeaviateObject<T>> => {
if (!object) {
return {} as WeaviateObject<T>;
}
Expand Down
7 changes: 5 additions & 2 deletions src/collections/serialize/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1504,8 +1504,8 @@ export class Serialize {
};

public static restProperties = (
properties: Record<string, WeaviateField>,
references?: Record<string, ReferenceInput<any>>
properties: Record<string, WeaviateField | undefined>,
references?: Record<string, ReferenceInput<any> | undefined>
): Record<string, any> => {
const parsedProperties: any = {};
Object.keys(properties).forEach((key) => {
Expand All @@ -1529,6 +1529,9 @@ export class Serialize {
});
if (!references) return parsedProperties;
for (const [key, value] of Object.entries(references)) {
if (value === undefined) {
continue;
}
if (ReferenceGuards.isReferenceManager(value)) {
parsedProperties[key] = value.toBeaconObjs();
} else if (ReferenceGuards.isUuid(value)) {
Expand Down