@@ -239,3 +239,112 @@ abstract class OBXPropertyType {
239239 /// < Variable sized vector of Date values (high precision 64-bit timestamp).
240240 static const int DateNanoVector = 32 ;
241241}
242+
243+ int externalTypeToOBXExternalType (ExternalType type) {
244+ switch (type) {
245+ case ExternalType .int128:
246+ return OBXExternalPropertyType .Int128 ;
247+ case ExternalType .uuid:
248+ return OBXExternalPropertyType .Uuid ;
249+ case ExternalType .decimal128:
250+ return OBXExternalPropertyType .Decimal128 ;
251+ case ExternalType .flexMap:
252+ return OBXExternalPropertyType .FlexMap ;
253+ case ExternalType .flexVector:
254+ return OBXExternalPropertyType .FlexVector ;
255+ case ExternalType .json:
256+ return OBXExternalPropertyType .Json ;
257+ case ExternalType .bson:
258+ return OBXExternalPropertyType .Bson ;
259+ case ExternalType .javaScript:
260+ return OBXExternalPropertyType .JavaScript ;
261+ case ExternalType .int128Vector:
262+ return OBXExternalPropertyType .Int128Vector ;
263+ case ExternalType .uuidVector:
264+ return OBXExternalPropertyType .UuidVector ;
265+ case ExternalType .mongoId:
266+ return OBXExternalPropertyType .MongoId ;
267+ case ExternalType .mongoIdVector:
268+ return OBXExternalPropertyType .MongoIdVector ;
269+ case ExternalType .mongoTimestamp:
270+ return OBXExternalPropertyType .MongoTimestamp ;
271+ case ExternalType .mongoBinary:
272+ return OBXExternalPropertyType .MongoBinary ;
273+ case ExternalType .mongoRegex:
274+ return OBXExternalPropertyType .MongoRegex ;
275+ default :
276+ throw ArgumentError .value (type, 'type' , 'Invalid ExternalType' );
277+ }
278+ }
279+
280+ /// A property type of an external system (e.g. another database) that has no default mapping to an ObjectBox type.
281+ /// External property types numeric values start at 100 to avoid overlaps with ObjectBox's PropertyType.
282+ /// (And if we ever support one of these as a primary type, we could share the numeric value?)
283+ abstract class OBXExternalPropertyType {
284+ /// Not a real type: represents uninitialized state and can be used for forward compatibility.
285+ static const int Unknown = 0 ;
286+
287+ /// Representing type: ByteVector
288+ /// Encoding: 1:1 binary representation, little endian (16 bytes)
289+ static const int Int128 = 100 ;
290+
291+ /// Representing type: ByteVector
292+ /// Encoding: 1:1 binary representation (16 bytes)
293+ static const int Uuid = 102 ;
294+
295+ /// IEEE 754 decimal128 type, e.g. supported by MongoDB
296+ /// Representing type: ByteVector
297+ /// Encoding: 1:1 binary representation (16 bytes)
298+ static const int Decimal128 = 103 ;
299+
300+ /// A key/value map; e.g. corresponds to a JSON object or a MongoDB document (although not keeping the key order).
301+ /// Unlike the Flex type, this must contain a map value (e.g. not a vector or a scalar).
302+ /// Representing type: Flex
303+ /// Encoding: Flex
304+ static const int FlexMap = 107 ;
305+
306+ /// A vector (aka list or array) of flexible elements; e.g. corresponds to a JSON array or a MongoDB array.
307+ /// Unlike the Flex type, this must contain a vector value (e.g. not a map or a scalar).
308+ /// Representing type: Flex
309+ /// Encoding: Flex
310+ static const int FlexVector = 108 ;
311+
312+ /// Placeholder (not yet used) for a JSON document.
313+ /// Representing type: String
314+ static const int Json = 109 ;
315+
316+ /// Placeholder (not yet used) for a BSON document.
317+ /// Representing type: ByteVector
318+ static const int Bson = 110 ;
319+
320+ /// JavaScript source code
321+ /// Representing type: String
322+ static const int JavaScript = 111 ;
323+
324+ /// A vector (array) of Int128 values
325+ static const int Int128Vector = 116 ;
326+
327+ /// A vector (array) of Int128 values
328+ static const int UuidVector = 118 ;
329+
330+ /// The 12-byte ObjectId type in MongoDB
331+ /// Representing type: ByteVector
332+ /// Encoding: 1:1 binary representation (12 bytes)
333+ static const int MongoId = 123 ;
334+
335+ /// A vector (array) of MongoId values
336+ static const int MongoIdVector = 124 ;
337+
338+ /// Representing type: Long
339+ /// Encoding: Two unsigned 32-bit integers merged into a 64-bit integer.
340+ static const int MongoTimestamp = 125 ;
341+
342+ /// Representing type: ByteVector
343+ /// Encoding: 3 zero bytes (reserved, functions as padding), fourth byte is the sub-type,
344+ /// followed by the binary data.
345+ static const int MongoBinary = 126 ;
346+
347+ /// Representing type: string vector with 2 elements (index 0: pattern, index 1: options)
348+ /// Encoding: 1:1 string representation
349+ static const int MongoRegex = 127 ;
350+ }
0 commit comments