Skip to content

Migration to 2.0 ​

2.0 is the first release that leaves the contract of the Scala mongocamp-server behind. 1.x reproduced it exactly, including behaviour that cost speed or gave surprising results. 2.0 fixes those places in one major release; there is no compatibility switch. This guide lists every change an application can notice, with the action it needs.

It applies to applications that used the Scala server or 1.x of this module, its embedded server or the standalone image. The switch from the Scala server itself (same database, same environment) is described in Migration from Scala; read that first if you come from Scala.

Checklist ​

  1. No Scala server on the same database any more. 2.0 rewrites password hashes at login and ignores tokens of the Scala server. A rollback to the Scala server on the same database locks out every user who logged in to 2.0.
  2. Start once with MIGRATION_DROP_SCALA_LEFTOVERS=true if the database was written by the Scala server (Quartz collections mc_jobs_* exist), then remove the setting. Without it the token cleanup job is listed but never runs.
  3. Expect one new login per user whose token was issued by the Scala server or by this server before 1.9.2.
  4. Regenerate clients that were generated from the 1.x spec (openapi/docs.yaml, now version 2.0.0). The module ships the regenerated client.
  5. Documents come as Extended JSON. Read _id with documentId(doc), typed values with fromExtendedJson(doc), or send extendedJson=plain for the 1.x format.
  6. Review saved Lucene filters: mixed AND/OR, negated groups, a -b, wildcards (now case-sensitive) and dates without a zone (now UTC).
  7. Handle 404 where 1.x answered 200 with null, false, zeros or empty lists.
  8. Imports are all or nothing: after an aborted import, send the whole body again.
  9. Schema routes sample 1000 documents; send sampleSize=0 for the old full scan.

What changes, at a glance ​

AreaChangeWhat an application built against 1.x / Scala loses or has to do
API contractspec 2.0.0, deepth → depthregenerate clients; deepth is ignored
Documentsrelaxed Extended JSON by defaultcode that reads _id or dates as strings breaks; use the helpers or extendedJson=plain
FiltersLucene boolean rulesa AND b OR c, a -b, -(a AND b) return other documents
Filtersvalue detection, empty filter007, 2014-04 are text, not dates; n:1* finds numbers; filter= matches all instead of 400
Filterscase-sensitive wildcardsname:abc* no longer finds ABCdef; send filterCaseInsensitive=true
Filtersdates without zone in UTClocal dates shift by the UTC offset of the server; set FILTER_TIME_ZONE
Errors404 / 400 for missing resourcescalls reject instead of resolving with null, false or zeros
Importall or nothinga failed import keeps nothing; resend everything
Schemavalid JSON schema, samplingtypes, definition names and counts change; sampleSize=0 for a full scan
Passwordssalted scrypt hashes, upgraded at loginthe Scala server cannot verify the password of a user who logged in to 2.0
Tokens and jobsScala leftovers ignoredone new login; one start with MIGRATION_DROP_SCALA_LEFTOVERS=true

API contract and client ​

  • The spec version is 2.0.0. Clients generated from the 1.x spec keep working for most calls but miss the new parameters and the renamed ones; regenerate them.
  • GET /mongodb/collections/{collectionName}/schema and /schema/analysis: the query parameter deepth is now depth. The old name is ignored (depth 3 applies). Client: getSchemaAnalysis({ collectionName, depth }).
  • GET /mongodb/collections/{collectionName}/fields: the query parameter sample size is now sampleSize.
  • Deprecated, still filled, to be removed in a later major: ClusterMemberInformation.siteMaster, siteAddress, multicast (always false), IndexOptionsRequest.background (ignored by MongoDB since 4.2). See Changes in 2.1 for what 2.1 removed and deprecated.

Documents: relaxed Extended JSON by default ​

List, find, search, get, aggregate and the json/ndjson export write documents as relaxed MongoDB Extended JSON when extendedJson is not sent. The types of ids, dates, decimals, binary values and regular expressions stay visible, so a document survives GET → PUT.

jsonc
// 1.x (and extendedJson=plain)
{"_id":"507f1f77bcf86cd799439011","n":5,"big":9007199254740993,"price":10.25,"when":"2024-06-15T12:00:00Z","note":"2024-06-15T12:00:00Z"}
// 2.0
{"_id":{"$oid":"507f1f77bcf86cd799439011"},"n":5,"big":{"$numberLong":"9007199254740993"},"price":{"$numberDecimal":"10.25"},
 "when":{"$date":"2024-06-15T12:00:00Z"},"note":{"$string":"2024-06-15T12:00:00Z"}}
  • Integers beyond 2^53 are {"$numberLong": ...} (a JavaScript client would round the number); other numbers stay plain numbers.
  • A text that looks like a date is {"$string": ...}: a plain ISO instant in a request body is stored as a date, the wrapper keeps a text a text when the document is sent back.
  • extendedJson=plain gives the 1.x format, extendedJson=canonical wraps every number too. A csv export stays plain unless extendedJson is sent.
  • A GET → PUT with the default keeps ObjectIds, dates, decimals, binary values, regular expressions, timestamps, big integers and date-like texts. Plain numbers are read as in 1.x: whole numbers are stored as Int64, so an Int32 or an integral double becomes Int64. Use extendedJson=canonical to keep every number type.
  • Unchanged: distinct values, file information, index and status maps, and the ids in insert and update responses (strings).

The module adds auto-imported helpers:

ts
const doc = await documentApi.getDocument({ collectionName: 'users', documentId: id })
documentId(doc)             // '507f1f77bcf86cd799439011'
const typed = fromExtendedJson(doc)   // ObjectId, Date, Decimal128, bigint for big integers
await documentApi.update({ collectionName: 'users', documentId: id, requestBody: toExtendedJson({ ...typed, seen: new Date() }) })

Lucene filters ​

Filters are the filter query parameter, the filter of the search body, of copy and of update/delete many.

Boolean rules ​

Groups follow Lucene: every required clause matches, no prohibited clause matches, optional clauses only count without a required clause. Filters with one operator (a AND b, a OR b, a b), single negations (-a, NOT a) and +a -b are unchanged.

Filter1.x matched2.0 matches
a AND b OR ca and b and ca and b (c is optional)
a OR b AND ca, or b and cb and c
a -ba, or anything without ba and not b
a b -ca or b or not c(a or b) and not c
-(a AND b)neither a nor bnot both

Write the intended grouping with parentheses: (a AND b) OR c. A group of prohibited clauses only (-a -b) still matches every document except them.

Values and the empty filter ​

  • A term is a date only as a full date with a four-digit year (2014-04-20, 2014-04-20T10:00, with a zone) or 20140420T100000Z. Partial forms are text now: 007 and +5 (1.x: the years 7 and 5), 2014-04, 2014-W16-7, 2014-110, T10:00, 2014-4-20.
  • A prefix or wildcard made of number characters also matches numbers by their decimal text: n:1* finds 10 and 123, price:*.5 finds 2.5. Such a filter cannot use an index.
  • An empty or blank filter (filter=) matches all documents (1.x: 400). Update and delete many still need matchAll=true for it.

Case-sensitive wildcards ​

Wildcards and prefixes (name:abc*, name:*abc, name:a?c, quoted values with *) match the case exactly, so a prefix uses an index on the field. Send filterCaseInsensitive=true for the 1.x behaviour (it reads the whole index or collection). The search composables take it as an option:

ts
usePaginatedFind('users', { filter: 'name:abc*', filterCaseInsensitive: true })
useMongocampSearch().find('users', 'name:abc*', 1, undefined, undefined, 20, true)

Dates without a zone ​

A date without Z or an offset (at:2014-04-20, also in ranges) is read in UTC, the same on every host; 1.x used the time zone of the server process. Set FILTER_TIME_ZONE (an IANA name like Europe/Berlin, or +05:30) to read them in another zone; it can be changed at runtime, and a name that is no time zone answers 500 on filters with a date. In a zone with daylight saving, a time in the gap of the change (2014-03-30T02:30 in Berlin) is no date and stays text, in the overlap the earlier instant counts. Dates with a zone are unchanged.

404 and 400 instead of 200 ​

The generated client now rejects these calls (ResponseError) where 1.x resolved with null, false, zeros or empty lists:

Request1.x2.0
GET …/index/{name}, index does not exist200 null404, code 27
GET /system/configurations/{key}, unknown key200 null404
PATCH /system/configurations/{key}200 {"value": false}404 unknown key, 400 read only or set by the environment
collection does not exist: GET info, /fields, /fields/detail, /schema, /schema/analysis, /index/stats, DELETE, DELETE …/clearzeros, [], true404
bucket does not exist: GET, DELETE, DELETE …/clearzeros, true404
DELETE …/files/{id}, file does not existdeletedCount: 0404
DELETE / PATCH / PATCH …/partial of one document that does not existcounts 0404
DELETE /mongodb/databases/{db}, database does not existtrue404
GET /mongodb/databases/{db}/collections, database does not exist[]404 for administrators, [] for everyone else
DELETE /admin/users/{id}, /admin/roles/{name}, /system/jobs/{group}/{name} that do not existfalse404

The many/* routes keep answering with their counts.

Import ​

POST …/documents/import is all or nothing: when an import is aborted (body over IMPORT_MAX_BYTES → 413, a line over 17 MB → 400, a database or connection error), the documents of the earlier batches are deleted again and x-error-additional-info says so. Send the whole body again. Lines that cannot be stored (invalid JSON, duplicate key) are still reported in errors while the valid lines are stored. The rollback deletes documents; it is not a transaction, so readers can see them until the abort.

Schema routes ​

  • /schema, /schema/analysis, /fields/detail and /fields analyse 1000 documents by default; sampleSize=0 reads every document. With a sample, counts and shares are estimates and rare fields can be missing.
  • The JSON schema of /schema validates against JSON schema draft 2020-12 and describes the plain format: an ObjectId is {"type": "string", "pattern": "^[0-9a-fA-F]{24}$"}, bool → boolean, decimal → number, timestamp → string with date-time, MinKey/MaxKey/undefined → null.
  • Fields with several types use anyOf (1.x: oneOf, which refused values that fit two types). Duplicate definition names are Name_1, Name_2 (1.x: Name}_1). Arrays with mixed elements list the element types.

Users, tokens and jobs ​

  • Passwords are stored as salted scrypt hashes. The SHA-256 hashes of the Scala server still work and are replaced at the next successful login (token or Basic auth); from then on a Scala server cannot verify that password. Basic auth remembers a verified password for 60 seconds while the stored hash stays the same. AUTH_USERS takes plain passwords as before, or a hash of the new format.
  • Tokens whose cache entry holds the token itself (Scala server, or this server before 1.9.2) are no longer accepted: one new login.
  • MIGRATION_DROP_SCALA_LEFTOVERS=true (environment, one start): drops the Quartz collections mc_jobs_*, deletes the token entries of the old format and rewrites the Quartz expression of the token cleanup job to croner syntax. A second run changes nothing.
  • New configurations: FILTER_TIME_ZONE and MIGRATION_DROP_SCALA_LEFTOVERS; the configuration list has 53 entries.

New in 2.0 (no action needed) ​

  • count=exact|none on the document, aggregate, distinct and file lists: none skips the count and its headers. Without a filter the count comes from the collection metadata.
  • Cursor paging on the document and file lists: send after= for the first page and the x-pagination-next header of the answer for the next one; deep pages cost the same as the first.
  • Api-key logins are found through an index.

Changes in 2.1 ​

2.1 drops the plugin model of the Scala server: extensions, request logging and metrics are Nitro 3 plugins.

ChangeAction
Removed: the settings PLUGINS_IGNORED, PLUGINS_URLS, PLUGINS_DIRECTORY, PLUGINS_MODULES, PLUGINS_MAVEN_REPOSITORIES, HTTP_CLIENT_HEADERS (49 configurations are listed)none; stored values are ignored, a start with MIGRATION_DROP_SCALA_LEFTOVERS=true deletes them
Removed: SettingsResponse.routesPlugins, filePlugins, ignoredPlugins of GET /system/settingsclients that read them use configurations only (the generated client is updated)
Deprecated (3.0): an embedded server switches request logging and metrics on from REQUESTLOGGING_ENABLED / METRICS_ENABLED, with a warningNuxt: mongocamp.server.requestLogging / metrics; own host: server.use(requestLogging()) / server.use(metrics()). The standalone server keeps the two settings
Deprecated (3.0): GET /system/monitoring/jvm (answers with Deprecation: true) and LOGGING_METRICS_MONGODB_JVM/system/monitoring/runtime and LOGGING_METRICS_MONGODB_RUNTIME; new snapshots go to monitoring_runtime, monitoring_jvm is left as it is
Monitoring routes are always registered and answer 404 while metrics are offnone
New: the events are Nitro hooks (mongocamp:<event>), mongocamp:ready hands over the serverlisteners can move from useMongocampCore() + core.events.on to a Nitro plugin; both keep working
Missing grant answers 403 (AUTH_GRANT_DENIED_STATUS default; any value but 401 is 403)a user who lacks a grant keeps the session; clients that rewrote the 401 (permissionDenied.ts of nuxt-ui-mongocamp) can drop that. AUTH_GRANT_DENIED_STATUS=401 restores the old status
Quoted values are exact: * in quotes is literal (name:"Ali*" no longer finds Alice)write a wildcard unquoted, with an escaped space: name:Ali*, name:John\ Do*
A quoted value that converts matches the value or the same text (note:"2024-06-15T12:00:00Z" finds the text)none
An inclusive bare date as upper bound covers its whole day (at:[* TO 2024-06-15], at:<=2024-06-15)clients that widened the bound to the end of the day can drop that
A prefix or wildcard on _id matches ObjectIds by their hex text (_id:6ad7*)none
Document reads of mc_users leave out password; distinct of it and projections that copy it answer 400use the admin routes for users
New: POST …/documents/count, POST …/documents/export and filter in the aggregate body (both query and body: 400, code 4004)move long filters into the body; the URL limit no longer applies
New: trailer=true on the export ({"$end":true,"count":n} / {"$error":"…"}, csv # end n)check the marker instead of counting lines
New: extendedJson on distinct (default stays plain)read big integers with extendedJson=relaxed
Spec: the schema UpdateRequest is UpdateManyRequest (the body of many/update), Grant.grantType is an enumregenerate clients; the parameter updateRequest of updateMany keeps its name, documentApi.update no longer clashes with the model
DELETE /admin/users/{id} of a missing user answers user <id> does not existnone

Changes in 2.3 ​

2.3 adds declared collections with behaviours, before-hooks and live updates. Nothing changes for an application that uses none of them.

ChangeAction
New: declared collections (server/mongocamp/*.ts, defineMongocampCollection, collections([...])): types, validation of API writes, MongoDB validatornone; opt-in per collection. Start with validation: 'warn' on collections with data
New: typed client composable useMongocampCollectionnone; the other composables keep their return types
New: before-hooks mongocamp:document:beforeInsert/Replace/Update/Deletenone
New: issues in the error body of invalid documents (codes 4010 and 121)none; read them for form errors
New: GET /mongodb/collections/{name}/schema/validatornone
A change of _id on replace answers 400 (code 66) instead of 500none
useMongocampApiCollection accepts Record<string, unknown> documents instead of string mapsnone (wider type)
Documents of declared collections are stored as the schema returns them: defaults applied, fields outside a z.object dropped, whole numbers as intuse z.looseObject to keep other fields
New: behaviours timestamps, owner, softDelete, versioned, audit, protectedFieldsnone; opt-in per collection. With owner on a collection with data: documents without owner can only be changed by administrators until the field is set
New: live updates (…/documents/watch, useMongocampLive)a replica set for streaming; without one the client polls
New: withDeleted, …/restore, …/history, /mongodb/collections/{name}/history, …/declarationnone
New: error codes 4092 (409, with current), 4281 (428), 5011 (501); ErrorDescription.currentnone
New hooks and payload fields: document:beforeRead, instead, onNoMatch, isAdmin, document:restore; events document:create.documents, document:update.source, document:delete.softDeletednone
New setting WATCH_MAX_STREAMS (50 configurations are listed)none
useMongocampCollection: replace / update with a document send its version, inputs leave out system and protected fieldsnone (behaviours only)

Changes in 2.4 ​

2.4 adds indexes and references to declared collections and a typed collection for server code. Nothing changes for an application that uses none of them.

ChangeAction
New: indexes in the declaration, synced at the start (own indexes mongocamp_idx_* only)none; indexes you made by hand stay. Declare them to have them in one place
New: refs in the declaration and expand on list, get, find, search, export and watchnone
New: useMongocampServerCollection / server.collection(name, { user })none; replaces useMongocampApi calls in your routes where you want types and the caller's rights
GET …/declaration answers indexes and refsregenerate clients that read it
ReadOperation of document:beforeRead has the new value 'expand' (the documents of an expansion)a hook that switches over all operations handles it like a read
DeclaredCollection has the fields indexes and refscode that builds one by hand adds indexes: [], refs: []
TypedCollection.find, findPage, findById and paginated are overloaded (typed expand)expectTypeOf(collection.find).returns in type tests: test a call instead
The document routes run on a shared service (context.documents); answers are unchangednone

Changes in 2.5 ​

2.5 adds no features: it hardens the server and the module (review of plan 06). An application keeps working; check the rows in bold.

ChangeAction
$where, $function and $accumulator are refused in the filters, projections and updates of clients and server code, and in the JSON filter of the file list of a bucket (403, code 4031; FILTER_OPERATORS_DENIED)if you use them on purpose: set FILTER_OPERATORS_DENIED to [] (or a shorter list)
CORS: an origin that is not in CORS_ORIGINS_ALLOWED gets no Access-Control-Allow-Origin (before: the first allowed origin, which browsers refused anyway); an empty list answers * without credentials; Vary: Originnone for browsers; tests that sent any origin and expected a header send an allowed one
Unexpected errors (500) answer a generic message; the log has the error under the x-request-id of the answer. MongocampErrors and database errors keep their messagesERRORS_EXPOSE_INTERNAL=true for development
New limits: BODY_MAX_BYTES (64 MiB) and WATCH_QUEUE_MAX (1000) on, PAGING_MAX_ROWS, EXPORT_MAX_DOCUMENTS, GRIDFS_UPLOAD_MAX_BYTES opt-in (Limits)none; set the opt-in ones, see the production checklist
Malformed input answers 400 (code 4001): an empty path parameter, an empty or broken body of the optional-body routesnone
A Last-Event-ID that is no resume token starts the live update with reset instead of 500; a standalone database is probed again after 30 snone
server.close() ends open live updates firstnone
New settings SERVER_HEADER_ENABLED, EXPORT_CSV_ESCAPE_FORMULASnone
Module: url is optional with the embedded server; runtimeConfig.mongocampServer only exists with server.enabledcode that read mongocampServer with an external server checks for undefined
Module: with an external server, useMongocampServerCollection is not auto-imported and neither the core nor the driver is bundlednone (it needs the embedded server)
Module: decoded documents (ObjectId, Decimal128, …) work in useAsyncData on the server (before: 500)none
Module: no state is shared between server-rendered requests (declarations, clients, token refresh); a failed lookup of a declaration is asked againnone
Module: a typed document is accepted by update, replace, remove, restore, history (client and server collection) without a cast; one without _id is refused (400)remove as never casts
Module: useMongocampLive keeps a patched list within its rows, reports events that are no JSON, opens no stream after a 401 / 403none
Module: findByField escapes backslashes and the field namenone
server-core: the entry separates the public API from building blocks (documented in the source); ValidationIssue, AuthService, MongocampDatabase, … are exportednone
Node 22.22 or newer (engines)upgrade older Node versions

Changes in 2.6 ​

2.6 takes over what the UI module nuxt-ui-mongocamp had to work around. Everything is additive; check the rows in bold.

ChangeAction
A Lucene term with 24 hex characters on a declared ref matches the ObjectId and the text: customerId:<hex> finds the orders of a customer, in every route with a Lucene filter (References)none; other fields are unchanged
A database created before 2.2 that still stores the old default 401 of AUTH_GRANT_DENIED_STATUS answers 403 after the start: a stored 401 that no update set is upgraded onceif you want 401: patch it again (an update is kept since 2.6)
The declaration answer: refs[].many is always given (false when neither the schema nor { collection, many } says an array), new referencedBy, and indexes[] with sparse, origin, partialFilterExpression, partialFilterFrom, expireAfterSecondsnone
A capped export says so: {"$end":true,"count":n,"capped":true} / # end n capped with trailer=true, header x-export-max-documents while EXPORT_MAX_DOCUMENTS is onnone
/system/capabilities tells every user bodyMaxBytes, pagingMaxRows, exportMaxDocuments, gridfsUploadMaxBytesnone
413 has codes: 4131 body (BODY_MAX_BYTES), 4132 upload (GRIDFS_UPLOAD_MAX_BYTES), 4133 import (IMPORT_MAX_BYTES); the messages are unchangedclients can branch on the code instead of the message
DELETE /system/configurations/{key} sets the default again (not for AUTH_SECRET)none
The current document of a version conflict (409, 4092) uses extendedJson of the request (relaxed without)none
POST /mongodb/buckets/{bucket}/files/search: file lists with a Lucene filter in the body; PAGING_MAX_ROWS applies to file lists toonone unless you set PAGING_MAX_ROWS
USERS_READ_HIDE_API_KEY (default false, true in 3.0): the document routes leave out apiKey of mc_users like passwordset it to true now if no client reads api keys from the document routes
Client: @sfxcode/nuxt-mongocamp-server/client exports the generated client, createMongocampApis(configuration, { keepLongs }), keepLongsMiddleware and parseJsonKeepingLongs (integers beyond 2^53 as { $numberLong })none
Client: AdminApi.generateNewApiKeyForUser is the fixed name; gnerateNewApiKeyForUser is a deprecated alias until 3.0rename the call

Two things that are not new but surprise in raw answers: UpdateResponse.upsertedIds holds the id of the changed document, also without a real upsert (the Scala contract); the version _v of a versioned collection starts at 0, and many/update / many/delete are not checked against it but count it up.

Changes in 2.8 ​

2.8 takes over a second round of findings from the applications on 2.6/2.7. Everything is additive; check the rows in bold.

ChangeAction
GET /system/configurations says where each value comes from: source (env, option, patched, stored, default), defaultValue and isDefault (Configuration)none
The start logs one warning with the keys whose stored value nobody set and that differ from the current default (an old default of an earlier server, or a value set before 2.6) — keys onlyafter an upgrade, read it once: DELETE /system/configurations/{key} takes the current default, PATCH keeps the value. 3.0 is planned to stop storing defaults
timestamps.preserveOnUpdate with the header X-MONGOCAMP-KEEP-TIMESTAMPS: true (or keepTimestamps of a server collection): an administrator's update or replace keeps the updatedAt / updatedBy it sends. With versioned: timestamp such a maintenance write is checked and does not advance the version (timestamps)none
GET /version adds core: { name, version }, the server core that runsnone; an application that bumped its own version only to report the core can stop
Server code: useMongocampEventApi(event, token?) is the name of the generated client for server routes; useMongocampApi(event) there is a deprecated alias until 3.0 (it shared the name of the browser composable, so editors picked the wrong one)rename the calls in server/
A copy with withIndexes leaves out the own indexes of a declaration (mongocamp_idx_*) unless the target is declared; the answer counts them as skippedIndexesnone
Client: update and updateDocumentPartial take extendedJson (the mode of current in a version conflict)none

nuxt-ui-mongocamp ​

Places in nuxt-ui-mongocamp that need a change for 2.0 (checked against its main branch of 2026-11-09):

  • Reads that switch to Extended JSON: the table of MongocampCollectionData.vue (searchDocumentsRaw), useMongocampFetchAll (collects _ids), useMongocampAggregation (aggregateRaw), the samples of MongocampCollectionInfos.vue (listDocuments), and the json/ndjson downloads of useMongocampExportAll. Quick fix: send extendedJson: 'plain'; better: read them with its useMongocampExtendedJson and unwrapId helpers.
  • useMongocampQuery.like builds field:"*value*", now case-sensitive: send filterCaseInsensitive: true for search boxes.
  • Not affected: the document editor (reads extendedJson: 'canonical'), the rewrite of negated AND groups (still correct), date bounds (already UTC).

Released under the MIT License.