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

DuplicateKeySyncError.md

239 lines4.7 KB

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