Skip to content
Source
Sign inSign up
TanStack/db
Open History to see the last commit

DuplicateKeySyncError.md

241 lines4.7 KB

1---
2id: DuplicateKeySyncError
3title: DuplicateKeySyncError
4---
5​
6# Class: DuplicateKeySyncError
7​
8Defined in: [packages/db/src/errors.ts:171](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L171)
9​
10## Extends
11​
12- [`CollectionOperationError`](CollectionOperationError.md)
13​
14## Constructors
15​
16### Constructor
17​
18```ts
19new DuplicateKeySyncError(
20 key,
21 collectionId,
22 options?): DuplicateKeySyncError;
23```
24​
25Defined in: [packages/db/src/errors.ts:172](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L172)
26​
27#### Parameters
28​
29##### key
30​
31`string` | `number`
32​
33##### collectionId
34​
35`string`
36​
37##### options?
38​
39###### hasCustomGetKey?
40​
41`boolean`
42​
43###### hasDistinct?
44​
45`boolean`
46​
47###### hasJoins?
48​
49`boolean`
50​
51#### Returns
52​
53`DuplicateKeySyncError`
54​
55#### Overrides
56​
57[`CollectionOperationError`](CollectionOperationError.md).[`constructor`](CollectionOperationError.md#constructor)
58​
59## Properties
60​
61### cause?
62​
63```ts
64optional cause: unknown;
65```
66​
67Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:26
68​
69#### Inherited from
70​
71[`CollectionOperationError`](CollectionOperationError.md).[`cause`](CollectionOperationError.md#cause)
72​
73***
74​
75### message
76​
77```ts
78message: string;
79```
80​
81Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1077
82​
83#### Inherited from
84​
85[`CollectionOperationError`](CollectionOperationError.md).[`message`](CollectionOperationError.md#message)
86​
87***
88​
89### name
90​
91```ts
92name: string;
93```
94​
95Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1076
96​
97#### Inherited from
98​
99[`CollectionOperationError`](CollectionOperationError.md).[`name`](CollectionOperationError.md#name)
100​
101***
102​
103### stack?
104​
105```ts
106optional stack: string;
107```
108​
109Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1078
110​
111#### Inherited from
112​
113[`CollectionOperationError`](CollectionOperationError.md).[`stack`](CollectionOperationError.md#stack)
114​
115***
116​
117### stackTraceLimit
118​
119```ts
120static stackTraceLimit: number;
121```
122​
123Defined in: node\_modules/.pnpm/@types+node@25.2.2/node\_modules/@types/node/globals.d.ts:67
124​
125The `Error.stackTraceLimit` property specifies the number of stack frames
126collected by a stack trace (whether generated by `new Error().stack` or
127`Error.captureStackTrace(obj)`).
128​
129The default value is `10` but may be set to any valid JavaScript number. Changes
130will affect any stack trace captured _after_ the value has been changed.
131​
132If set to a non-number value, or set to a negative number, stack traces will
133not capture any frames.
134​
135#### Inherited from
136​
137[`CollectionOperationError`](CollectionOperationError.md).[`stackTraceLimit`](CollectionOperationError.md#stacktracelimit)
138​
139## Methods
140​
141### captureStackTrace()
142​
143```ts
144static captureStackTrace(targetObject, constructorOpt?): void;
145```
146​
147Defined in: node\_modules/.pnpm/@types+node@25.2.2/node\_modules/@types/node/globals.d.ts:51
148​
149Creates a `.stack` property on `targetObject`, which when accessed returns
150a string representing the location in the code at which
151`Error.captureStackTrace()` was called.
152​
153```js
154const myObject = {};
155Error.captureStackTrace(myObject);
156myObject.stack; // Similar to `new Error().stack`
157```
158​
159The first line of the trace will be prefixed with
160`${myObject.name}: ${myObject.message}`.
161​
162The optional `constructorOpt` argument accepts a function. If given, all frames
163above `constructorOpt`, including `constructorOpt`, will be omitted from the
164generated stack trace.
165​
166The `constructorOpt` argument is useful for hiding implementation
167details of error generation from the user. For instance:
168​
169```js
170function a() {
171 b();
173​
174function b() {
175 c();
177​
178function c() {
179 // Create an error without stack trace to avoid calculating the stack trace twice.
180 const { stackTraceLimit } = Error;
181 Error.stackTraceLimit = 0;
182 const error = new Error();
183 Error.stackTraceLimit = stackTraceLimit;
184​
185 // Capture the stack trace above function b
186 Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
187 throw error;
189​
190a();
191```
192​
193#### Parameters
194​
195##### targetObject
196​
197`object`
198​
199##### constructorOpt?
200​
201`Function`
202​
203#### Returns
204​
205`void`
206​
207#### Inherited from
208​
209[`CollectionOperationError`](CollectionOperationError.md).[`captureStackTrace`](CollectionOperationError.md#capturestacktrace)
210​
211***
212​
213### prepareStackTrace()
214​
215```ts
216static prepareStackTrace(err, stackTraces): any;
217```
218​
219Defined in: node\_modules/.pnpm/@types+node@25.2.2/node\_modules/@types/node/globals.d.ts:55
220​
221#### Parameters
222​
223##### err
224​
225`Error`
226​
227##### stackTraces
228​
229`CallSite`[]
230​
231#### Returns
232​
233`any`
234​
235#### See
236​
237https://v8.dev/docs/stack-trace-api#customizing-stack-traces
238​
239#### Inherited from
240​
241[`CollectionOperationError`](CollectionOperationError.md).[`prepareStackTrace`](CollectionOperationError.md#preparestacktrace)