Skip to content

Server 2.0 and later ​

The module needs MongoCamp server 3.2 or later (mongocamp-nitro-server, from @sfxcode/nuxt-mongocamp-server ^3.2.1) and @sfxcode/nuxt-ui-formkit ^1.8.0. It runs embedded in your Nuxt app (mongocamp.server.enabled) or as the standalone image of the same package. The Scala mongocamp-server and the 1.x line are no longer supported, and there is no compatibility code for them.

The dependency needs Nitro 3, so add nitro to your app's dependencies; it is a peer dependency of this module.

ts
// nuxt.config.ts — the embedded server
export default defineNuxtConfig({
  modules: ['@sfxcode/nuxt-ui-mongocamp'],
  mongocamp: {
    server: { enabled: true, config: { CONNECTION_DATABASE: 'mongocamp' } },
    refreshToken: true,
  },
})

The server's own migration guide (docs/migration-2.0.md in @sfxcode/nuxt-mongocamp-server) covers the database side: moving from the Scala server, password hashes, and MIGRATION_DROP_SCALA_LEFTOVERS.

What changes for your code ​

  • Documents are relaxed Extended JSON. Ids are { $oid }, dates { $date }, integers beyond 2^53 { $numberLong }, decimals { $numberDecimal }, and date-like text { $string }.

    • Plain values come from idOf (@sfxcode/nuxt-ui-mongocamp/utils) and unwrapExtendedJson (useMongocampExtendedJson).
    • useMongocampFetchAll rows come in this form.
    • MongocampExportAll / useMongocampExportAll JSON and NDJSON files do too. Pass extendedJson: 'canonical' (the Keep exact number types checkbox) and a re-import keeps Int32/Int64/Double exactly.
    • CSV stays plain.
  • Wildcards are case-sensitive on the server.

    • The module still searches case-insensitively by default: it sends filterCaseInsensitive=true with every wildcard filter.
    • Match case in MongocampQueryBar (QueryState.matchCase, kept with saved queries) switches to the fast case-sensitive match.
    • Components that take a filter got a matchCase prop. The composables take filterCaseInsensitive.
  • Lucene follows Lucene. useMongocampQuery now writes the direct forms:

    • _exists_:f for every type. Like MongoDB $exists, it is also true for null, '' and [].
    • open ranges as *.
    • -( … ) for negated groups; the De Morgan rewrite is gone.
    • f.0:* for a non-empty array.

    A bare date is midnight UTC; as the inclusive upper bound the server reads it as the whole day, so inRange and onDay write the date as given ([2024-06-15 TO 2024-06-15]). fuzzy and boost are refused by the server (400).

  • Quoted values are exact. A * inside quotes is literal, and a quoted value that converts (a date, a number) also finds the same text — note:"2024-06-15T12:00:00Z" finds a stored date and date-like text. The module writes wildcards unquoted (name:John\ Do*), so its own filters are unaffected; check hand-written ones.

  • Saved raw Lucene strings keep their text, and the server now reads them by Lucene's rules. In particular, a AND b OR c means "a and b"; write (a AND b) OR c.

  • 404 instead of 200 false. Deletes treat "already gone" as done: users, roles, jobs, collections, bucket files, buckets, and documents in the data table. useMongocampError has a notFound kind. A missing collection shows an error on its info page.

  • byId / byIds also take { $oid }. The filter of the bucket file list (useMongocampFiles().listFiles) is a MongoDB query as JSON text, not Lucene; the server ignores a Lucene string there and returns every file.

  • NDJSON import is all or nothing. After an aborted import, nothing is kept; send the whole file again.

What the module uses from 2.0 ​

Server featureWhere you see it
count=nonesamples, $indexStats and stage previews skip the count (runAggregation(…, { skipCount: true }))
cursor paging (after= / x-pagination-next)useMongocampFetchAll pages by cursor; the data table steps next/previous by cursor and sorts by a total order (the chosen sort, then _id). Through CORS (an external server on another origin) the browser can only read x-pagination-next when CORS_HEADERS_EXPOSED lists it: a database first started before 2.7.1 stored a list without it, and cursor reads silently stopped after the first page — server 2.7.1 upgrades such a stored list once
filterCaseInsensitivequick search, filter builder, select-all-matching, export, charts, aggregation, copy
GET /system/capabilities (every user)the MongoDB badge of MongocampVersion for non-administrators; /system/info and /system/stats are for administrators
schema analysis sampleSizefull analysis up to 1 000 000 documents (the server reads ~86 000 per second)
filters in the request body (2.2)count (POST …/documents/count), export (POST …/documents/export) and aggregation (filter in the body) take filters of any length
export end marker trailer=true (2.2)NDJSON and CSV exports end with the server's end or error marker; the module removes it from the file and reports a file without an end marker as incomplete
_id by hex text (2.2)the filter builder offers starts with / ends with / contains on _id (hex characters, any case)
validation issues (2.3)a document refused by a declared schema, a before-hook or the collection's validator: the save, delete, import and bulk-edit dialogs name the fields (describeServerError, kind invalid, issues)
version conflict 409 / 4092 (2.3)an edit in the data table opens the merge dialog MongocampVersionConflict; elsewhere: "Someone else changed this document …"
version required 428 / 4281 (2.3)the data table sends the version with every edit; a document stored without one gets "reload and change it again"
declared-collection behaviours (2.3)see Declared collections: declaration card, read-only system fields, soft delete + restore, history
declared indexes (2.4)MongocampIndexes marks them declared (an own index the declaration dropped: removed at next start) and warns before dropping one
references + expand (2.4)a References menu in the data table's query bar; referenced documents shown by name, opened in the view drawer; Show references in the view; export-all JSON/NDJSON can expand
denied operators $where / $function / $accumulator (2.5)a refusal names the operator (describeServerError, kind notAllowed); the module never sends them
limits (2.5)a body or file over BODY_MAX_BYTES / GRIDFS_UPLOAD_MAX_BYTES (413) names the limit, an import batch that is too large is split in halves and sent again; PAGING_MAX_ROWS: the data table pages with the size the server used and says so
limits in the capabilities, 413 codes (2.6)the module reads bodyMaxBytes, pagingMaxRows, exportMaxDocuments, gridfsUploadMaxBytes from /system/capabilities (useMongocampLimits): the data table and the bucket list offer no page size above the cap, export-all says before the export that it is cut, an upload over the limit is refused without sending it; codes 4131 / 4132 / 4133 get their own messages; MongocampServerInfo lists all limits
capped exports (2.6)export-all reads capped from the end marker (NDJSON/CSV) and x-export-max-documents (JSON) — fewer documents because some were deleted meanwhile is no longer mistaken for the limit
declaration details (2.6)indexes a behaviour asked for are badged for owner (…), the declaration card shows sparse and the soft-delete partial filter; refs[].many and referencedBy are read
bucket file search (2.6)MongocampBucketFiles searches with Lucene in the body of POST …/files/search (no URL limit); PAGING_MAX_ROWS applies to file lists
request id (2.5)a failed answer (5xx) shows its x-request-id in MongocampErrorAlert, with a copy button; the generic 500 text becomes a readable message
suggested validator GET …/schema/validator (2.3)Suggest validator in MongocampCollectionInfos (useMongocampAdmin().getSuggestedValidator)

Server settings worth knowing ​

  • AUTH_GRANT_DENIED_STATUS: the status of a missing grant, 403 by default. Server 2.6 upgrades a 401 that an older first start stored; a 401 set on purpose stays. On a 401 the dependency would clear the session, so the module turns that 401 into a 403 (useMongocampClientApi), and MongocampSettings shows a hint while the setting is 401.
  • USERS_READ_HIDE_API_KEY (2.6, default false): the document routes leave out apiKey of mc_users. The module strips password and apiKey from every mc_users row anyway.
  • FILTER_TIME_ZONE: the zone of dates without one in a filter (default UTC). The module always writes UTC (Z).
  • IMPORT_MAX_BYTES: the size limit of an NDJSON import (413 above it).

Updating from 3.1 to 3.2 ​

  • Raise @sfxcode/nuxt-mongocamp-server to ^3.2.1. What 3.2 changes:
    • inserts, replaces and imports refuse field names that start with $ (any depth) or contain . (top level) with a 400 naming the fields (DOCUMENTS_CHECK_FIELD_NAMES, default on; a declaration's checkFieldNames: false wins). A dotted name is unreachable anyway — every partial update, filter and sort reads a.b as a path. The import wizard now refuses such names before sending: a CSV column like address.city stops at the header, a JSON key with a dot (at any depth) refuses its row, like a $ key already did. The data table's partial updates are unaffected ($set paths may contain dots); an edit of an old document that still stores a dotted top-level name falls back to a replace, which 3.2 refuses with that 400;
    • a multipart upload's own UTF-8 file name is stored as sent (2.8–3.1 read it as latin1; the module was never affected, it sends fileName);
    • audit records carry their own id (the auditId of a restore) and actedBy (writes with X-AUTH-ACT-AS) — no UI for either yet.

Updating from 3.0 to 3.1 ​

  • Raise @sfxcode/nuxt-mongocamp-server to ^3.1.0. Nothing breaks; the module uses what 3.1 adds:
    • the capabilities announce the auth flows — Invite User in MongocampUsers shows itself when the server runs AUTH_REGISTRATION=invite (the invite prop still forces it). The logged-out pages keep their props: the capabilities need a login;
    • users change their own display name on MongocampAccount (PATCH /auth/profile);
    • deleting a running queue job says so (409, code 4094) instead of "gone";
    • a mongocamp:ready listener added after the core started is called, so the documented queue-handler pattern works in any plugin order;
    • createMongocampApis shares one middleware list across its APIs again (3.0 gave each its own).
  • Still not possible: a user changing their own e-mail address (an administrator does it in the users list).

Updating from 2.11 to 3.0 ​

  • Raise @sfxcode/nuxt-mongocamp-server to ^3.0.0 and read the server's own migration guide (docs/migration/to-3.0.md of the server): its breaking changes are server defaults, each with a way back.
  • What changes in the module, and what you may have to do:
Server changeIn the moduleYour part
* grants no longer reach mc_*, system.*, a bucket's .files / .chunks, .variantsthe permission matrix and useMongocampPermissions follow the new rulea role that really needs one of them gets a grant naming it (way back: none — use an administrator role)
mc_users reads leave out apiKey too (USERS_READ_HIDE_API_KEY=true)the data table already stripped it—
plain whole numbers are stored as Int64the data table's typed saves keep the original types; a new field goes in as the server stores itsend { "$numberInt": "3" } where you need Int32
RATE_LIMIT_LOGIN defaults to 10/15mthe login form shows the wait (429)behind a proxy set RATE_LIMIT_TRUSTED_PROXIES
one error type MongocampRequestError (a ResponseError)nothing to change—
new error codes 4013, 4014, 4035, 4093, 4403, 5031readable messages in useMongocampError, the login and the error alert—
$lucene in bulk bodiesdelete/update by filter send the filter in the body — no length limit—
  • New and opt-in — each needs the server setting and a prop or a page of yours (the server announces only sessions), see Authentication flows:
    • user fields (display name, e-mail, verified, disabled, last login) and Disable / Enable in MongocampUsers, shown in MongocampAccount;
    • sessions (AUTH_SESSIONS) — the Sessions card of the account page;
    • registration / invitation / verification (AUTH_REGISTRATION) — MongocampRegister, MongocampVerifyEmail, Invite User (invite prop);
    • password reset (AUTH_PASSWORD_RESET) — MongocampResetPassword, the login's forgot-password;
    • login by e-mail (AUTH_PASSWORDLESS) — the login's passwordless, MongocampLoginLink;
    • the app must send the mails: a Nitro hook mongocamp:auth:mail (the server sends none);
    • the job queue — the Queue section of MongocampJobs;
    • webhooks — MongocampWebhooks under paths.webhooks (add a page there if you use the module's navigation);
    • embeddings — a row on the declaration card.
  • The four auth pages are public: paths.register, verifyEmail, resetPassword, loginLink default to the paths of the server's mailed links (AUTH_APP_URL + /register …) and must not match a protected route pattern.
  • Server code on 3.0.0: a mongocamp:ready hook registered after another plugin started the core never fires — register queue handlers on the core (useMongocampCore().then(server => server.queue.handle(...))). Server 3.1 calls such a late listener at once, so the documented hook works again.
  • In server proxy mode there is no login: the auth pages show a note, the account page has no sessions card.
  • Not covered: OAuth / identities, two-factor login, the MCP endpoint, the outbox, vector search, hooks in the declaration.

Updating from 2.8 to 2.11 ​

  • Raise @sfxcode/nuxt-mongocamp-server to ^2.11.0.
  • useMongocampBucket is renamed to useMongocampFiles. The dependency now auto-imports its own typed bucket composable useMongocampBucket(name) (list, info, upload, update, remove, link of one declared bucket), which wins the auto-import — a call of the old useMongocampBucket() without a name now reaches the dependency's composable. Replace it with useMongocampFiles(); the returned functions and refs are unchanged.
  • Everything else is additive and only shows where your server declares it:
    • full-text search (search in a declaration) — a search box in the query bar;
    • declared views — a Views button in the data table, MongocampCollectionView;
    • drafts — the Drafts switch, status badges, the Publishing menu (useMongocampDrafts);
    • restore a version from the history (useMongocampHistory().restoreVersion);
    • access rules and tenants on the declaration card, and readable refusals (403, code 4033);
    • file references and declared buckets — file cells, the bucket badge and referencing collections;
    • signed file links (Share link, Revoke all links) — in proxy mode let /files/signed/ through your guard hook (Server proxy auth);
    • image variants by preset (thumbnailPreset, previewPreset; needs sharp where the server runs);
    • health (/health/ready in the status block, /health/live for the offline check), rate limits on the server page and the login form;
    • backups and migrations — MongocampMaintenance under paths.maintenance (add a page there if you use the module's navigation).
  • Server 2.9 stores an empty API key as no key; the module no longer sends one.
  • Known server gaps (2.11.0): export and aggregate ignore q; a partial edit of a published document leaves no "pending changes" marker in the working copy; fields/detail lists fields a field rule hides; the bucket information does not answer the declared types or variants.

Updating from 2.6 to 2.8 ​

  • Raise @sfxcode/nuxt-mongocamp-server to ^2.8.0; nothing else to change in an app that only uses this module.
  • Your own server code calls the dependency's client useMongocampEventApi(event, token?) now; the server-side useMongocampApi(event) still works but is deprecated (it clashed with the browser composable) and goes in 3.0.
  • What the module uses since 2.8:
    • Copy of a declared collection into an undeclared one leaves the declaration's own mongocamp_idx_* indexes out; the copy dialog says how many (skippedIndexes). Copies made before 2.8 keep theirs (not managed here badge).
    • Dropping an index that is already gone (404, code 27) counts as dropped.
    • Version conflicts: the data table's edit writes ask extendedJson=canonical, so the stored document of a 409 keeps its exact types and the merged save sends the version as it was stored.
    • Settings shows where each value comes from (env, option, changed, stored, default), the default under a value that differs, and warns about stored values an older server wrote that nobody changed.
    • Version: the badge's tooltip and the server info page name the server core.
    • Declared collections: timestamps.preserveOnInsert / preserveOnUpdate (and owner.preserveOnInsert) let an administrator's write keep the creation/change fields it sends. The declaration card names them; the import wizard says whether the file's values are kept and no longer adds its own metaData stamp to a collection with declared timestamps.
  • Fixed on the server, nothing to do: an older stored CORS_HEADERS_EXPOSED without x-pagination-next (cursor paging through CORS stopped after page 1) and an AGGREGATION_STAGES_DENIED without $collStats/$indexStats are upgraded once at the start (2.7.1/2.7.2); downloads name non-ASCII files correctly (filename*).
  • Known in 2.8 (fixed in 3.2): a multipart upload's own file name is read as latin1 (Übersicht ⇒ Ãbersicht) — the module always sends the name as the fileName parameter, which keeps it; and the declaration does not answer owner.preserveOnInsert yet (the server honours it).
  • New on the server, no UI in the module: X-AUTH-ACT-AS (an administrator acts for a user) and X-MONGOCAMP-KEEP-TIMESTAMPS.

Updating from 2.5 to 2.6 ​

  • Raise @sfxcode/nuxt-mongocamp-server to ^2.6.0 and @sfxcode/nuxt-ui-formkit to ^1.8.0 (the reference picker needs 1.8: earlier FUSelectMenu versions empty the search box after every key); nothing else to change.
  • The edit form relies on nuxt-ui-formkit 1.6 for irregular documents: a field that is null where other rows hold an object opens as an empty group (its fields optional) and is saved as null again; system and protected fields use its readonly overrides.
  • useMongocampBucket().listFiles (now useMongocampFiles) has a lucene option (POST …/files/search); the JSON filter option still works. uploadFiles takes maxBytes. New: useMongocampLimits.
  • Server proxy mode builds its client with createMongocampApis of @sfxcode/nuxt-mongocamp-server/client; useMongocampAdmin().regenerateUserApiKey calls generateNewApiKeyForUser.
  • Configurations can be reset: DELETE /system/configurations/{key} (the module's Settings page stays read-only).

Updating from 2.3 to 2.5 ​

  • Nothing to change in your code; the module's baseline is 2.5 (@sfxcode/nuxt-mongocamp-server ^2.5.0).
  • New in the UI: declared indexes and references (2.4), the 2.5 limits and the request id — see the table above.
  • Limits are runtime settings (PATCH /system/configurations/{key}, no restart). PAGING_MAX_ROWS, EXPORT_MAX_DOCUMENTS and GRIDFS_UPLOAD_MAX_BYTES are off by default. (Since 2.6 every user reads them from /system/capabilities.)
  • EXPORT_CSV_ESCAPE_FORMULAS protects the server's CSV export; the data table's own page export offers the same as Export page as CSV for spreadsheets.
  • Live updates (useMongocampLive) still need a replica set and have no UI in the module.

Updating from 2.2 to 2.3 ​

  • useMongocampCollection is renamed to useMongocampCollectionPaging. The dependency now auto-imports its own typed collection composableuseMongocampCollection(name) (find, insert, update, remove, restore, history, …), which wins the auto-import — a call of the old useMongocampCollection() without a name now reaches the dependency's composable. Replace it with useMongocampCollectionPaging(); the returned refs are unchanged.
  • Everything else is additive: declared collections (server/mongocamp/*.ts), their behaviours (timestamps, owner, soft delete, versioned writes, audit), live updates (useMongocampLive) and before-hooks only apply to collections you declare. The module's components keep working on any collection; on a declared one an invalid write now says which fields were refused.

Updating from 2.0 to 2.2 ​

  • MongocampSettings has no plugins card any more and its hidePlugins prop is gone; useMongocampSystem().getSettings() and the ServerPlugins type are removed. The server dropped its plugin model (extensions are Nitro plugins now), so /system/settings holds only the configuration map — which the module never reads there.
  • FilterTooLongError is gone: count, export and aggregation send their filter in the request body.
  • An NDJSON or CSV file from useMongocampExportAll no longer needs expected to be checked; documents is the server's own count.
  • The generated client renamed the model UpdateRequest to UpdateManyRequest, and Grant.grantType is an enum (COLLECTION, BUCKET, BUCKET_META).
  • Your stored AUTH_GRANT_DENIED_STATUS stays as it was (see above).

Still in place ​

  • Filters that travel in a URL are capped at 6 000 encoded characters: the bucket file list, and the data table's link to the aggregate page (the filter is in the page's URL). A proxy in front of a server may refuse longer URLs.
  • The data table still strips password and apiKey from mc_users rows. 2.2 leaves out password itself, but an administrator's read still contains the API key.
  • The aggregation builder refuses the server's default deny-list up front ($out, $merge, $function, $accumulator, $where, $currentOp, $listSessions, $collStats, $indexStats). Joins are allowed; the server checks their grants.

Released under the MIT License.