Repository navigation
Releases
@forestfuture/active-record@0.10.0
Minor Changes
-
#551
1fc6fceThanks @christopherstyles! - InsidewithDatabase, a read whose SQL and bound values match one already sent on that database is answered from memory, with no round trip, until a write clears it. Each answer is new records.onQueryhears a cached answer withcached: true. Any write Active Record sends inside the call clears the cache, through any database handle, and so doesreload(). A write you send yourself on the binding or apgclient doesn't, so call the newdb.clearRequestCache()after one. Turn the cache off withconnect(env.DB, { cache: { request: false } }). -
#535
bef8761Thanks @christopherstyles! -upsertandupsertAlltakeupdateOnly, naming the only attributes a clashing row has updated:upsertAll(rows, { uniqueBy: "email", updateOnly: ["name"] }). An upsert now sets a clashing row'supdatedAtonly when a value it updates changes, so writing a row again as it was keeps itsupdatedAt. An upsert with nothing to update butupdatedAt(every attribute it would update is auniqueByone or read-only) now leaves a clashing row alone, and doesn't count it inrowsAffectedor return it inrows.
Patch Changes
-
#549
cf395ceThanks @christopherstyles! - Acolumn(), a typed value orincoming()given asfind's id, or one of its ids, now throwsTypeErrorsaying to give the value itself, instead ofRecordNotFound.One nested in a json value (
where({ settings: { theme: column("x") } }),build,update,updateAll,insert, or a value changed in place and saved) now throws the sameTypeError, naming its path (settings.theme), for a custom type stored as json too. It used to match or store the reference's JSON. -
#548
9f6bc66Thanks @christopherstyles! - Acolumn(), a typed value (column(name).value(v)) orincoming()given as an attribute's value now throwsTypeErrorsaying where it belongs. In a condition orupdateAll, acolumn()orincoming()says to write it in ansqlfragment, and a typed value says to give the value itself. It used to match nothing, store the reference as a json attribute's JSON, or throw a cast error that didn't say why. In a written row (insert,upsert,createWith) or a record (build, a setter,update), it says to give the value itself. -
#541
ef696feThanks @christopherstyles! -upsertandupsertAlltakeonDuplicate, saying what a clashing row's attributes become, each ansqlfragment or a value:upsertAll(rows, { uniqueBy: "name", onDuplicate: { count: sql`${column("count")} + ${incoming("count")}` } }). In its fragments,column()is the clashing row's value, and the newincoming()is the new row's.
@forestfuture/active-record@0.9.1
Patch Changes
- #528
8405349Thanks @christopherstyles! - Add read-only records and attributes (#358).Relation.readonly()marks the records it loads, andrecord.markReadonly()marks one;isReadonly()reads the mark. Saving, updating, destroying or touching a read-only record, or writing its columns, throwsReadonlyRecord(.record,.action) before validation or any callback runs, and so does a save, batch,pushor associationtouchthat would write one through its associations. Bulk writes ignore the mark. An attribute declaredreadonly: trueis written when its record is created; assigning a persisted record another value throwsReadonlyAttribute(.attribute), while assigning the value it holds is allowed, so a form can post it back. Changing one another way (a belongsTo pointed elsewhere, a JSON value changed in place, a touch) is refused before anything is sent, while a counter cache still counts a read-only column. An upsert leaves a clashing row's read-only values alone.
@forestfuture/active-record@0.9.0
Minor Changes
- #526
9f21d78Thanks @christopherstyles! - Lock records optimistically with alock_versioncolumn (#357). A Model with an integerlockVersionattribute checks it on every save, destroy andtouch(), and adds 1 to it: a copy loaded before another write changed its row throwsStaleRecord(.record,.action), fromsave()anddestroy()as from theirOrThrowforms, and nothing in its batch is kept. An assignedlockVersion, such as a form's hidden field, is the version checked. A NULLlock_versionreads as 0. A belongsTo's or hasOne'stouchof a locked record adds 1 to its version without checking it. This is a minor change because a table that already has alock_versioncolumn starts locking.
Patch Changes
-
#514
1b61370Thanks @christopherstyles! - Give an attribute a second name withaliasOf(#509):static override attributes = { title: { aliasOf: "name" } } as const, or the same indefine. The alias reads and writes the attribute, typed as it, and queries, writes, validations, and change tracking take either name.attributes(),toJSON(), andchanges()list the attribute's own name. -
#516
edd95feThanks @christopherstyles! - Normalize an attribute's values withthis.normalizes("email", { with: (email) => email.trim().toLowerCase() })in a Model'sstatic {}(#354). Each value assigned to it is normalized once cast: through the setter,build,create,update, a default, and bulk writes such asinsertandupdateAll. A query's values are normalized as well, sofindBy({ email: " Jane@Example.com" })findsjane@example.com.nullis left alone unlessapplyToNull: true.Model.normalizeValueFor(name, value)returns a value normalized, andrecord.normalizeAttribute(name)normalizes a value loaded from a row stored before the normalization was declared. -
#513
d4107bdThanks @christopherstyles! -active-record generate modelwith a plural name now notes only the singular Model it makes:line_items looks plural, so the Model is LineItem(#511). The app base class thatinitandschemawrite describes itself and its filter defaults without naming another framework. -
#518
26841efThanks @christopherstyles! - Keep a password as a salted digest withpassword: { securePassword: true }instatic attributes, and give each new record a random token withauthToken: { secureToken: true }(#355). A secure password addspassword,passwordConfirmation, andpasswordChallenge, is hashed intopasswordDigestwith PBKDF2-SHA256 when the record is saved, and is left out oftoJSON()with its digest.await user.authenticate(password)checks it, andawait User.authenticateBy({ email, password })finds a record and checks its password in one step. Its validations require it, check its confirmation and challenge, and allow at most 72 bytes.{ securePassword: { algorithm } }plugs in another hash, such as bcrypt. A secure token is 24 characters of base58, made as the record is built, or withon: "create"as it's created, andregenerateAuthToken()saves a new one. Secure passwords, their digests, and secure tokens are always filtered from logs and errors, and left out oftoJSON().generateSecureToken(length)makes a token for anything else. -
#521
335350bThanks @christopherstyles! - Sign tokens with the Worker's secret (#517).await user.signedId({ purpose, expiresIn })signs a record's id, andUser.findSigned(signedId, { purpose })finds it again.this.generatesTokenFor("emailConfirmation", { expiresIn: { days: 1 }, dependsOn: (user) => user.email })instatic {}declares tokens for a purpose:await user.generateTokenFor(purpose)makes one, andUser.findByTokenFor(purpose, token)finds its record until it expires or the value it depends on changes. A secure password gets a reset token,await user.passwordResetToken(), found withUser.findByPasswordResetToken(token): it lasts 15 minutes and stops working once the password changes (securePassword: { resetToken: false }leaves it out). The finders are Relation methods too, keeping conditions and default scopes, and each has anOrThrowthat throws the newInvalidTokenfor a token that isn't valid. Tokens are signed with HMAC-SHA256 under the Worker'sSECRET_KEY_BASE, or what a Model'sstatic signingSecret(env)returns, a list to rotate secrets. -
#510
d7c746cThanks @christopherstyles! - Declare an attribute that isn't a column withvirtual: true(#356), such as a form'stermsOfServicecheckbox:static override attributes = { termsOfService: { type: "boolean", virtual: true } } as const, or the same indefine. It's typed, cast, change-tracked, and taken bypermit, but never saved, never loaded from a row, and refused in a query. The newconfirmationvalidator compares an attribute with its virtual confirmation (emailwithemailConfirmation), andtoJSON()leaves that confirmation out.
@forestfuture/active-record@0.8.2
Patch Changes
-
#503
5e2ff2fThanks @christopherstyles! - Around callbacks (#48), as Rails'around_save,around_create,around_update, andaround_destroy:this.aroundSave(async (order, next) => { …; await next(); … })runs code on both sides of a write.next()runs the rest of the save and resolves once the database has kept its batch; in abatch(), every record's first part runs before the one write. Not callingnext()stops the save, asabort()does. When the write is refused, or never sent because another record was refused,next()rejects with the save's error. -
#498
38cdf12Thanks @christopherstyles! - A belongsTo takestouch(#353), as Rails'belongs_to … touch::belongsTo(Article, { touch: true })sets the article'supdatedAtwhenever a comment is created, updated, destroyed, or touched, in the comment's own atomic batch.touch: "lastCommentedAt", or a list, sets those attributes too. The article is loaded first when it isn't, so it runs itsafterTouchand update commit callbacks, and touches the records its ownbelongsTos touch in turn. -
#501
5ab6414Thanks @christopherstyles! - A hasOne takestouch(#497), as Rails'has_one … touch::hasOne(Profile, { touch: true })sets the profile'supdatedAtwhenever its user is updated, destroyed, or touched, in the user's own atomic batch.touch: "lastSeenAt", or a list, sets those attributes too. The profile runs itsafterTouchand update commit callbacks. A created user touches nothing. A profile the user's own save writes (built through it, or autosaved), or the user'sdependentremoves, is left to that write; one saved as another entry of the same batch is still touched. -
#502
78846f8Thanks @christopherstyles! -afterFindandafterInitializecallbacks (#49), as Rails'after_findandafter_initialize: every record loaded (by a query, an association read, a preload, orreload()) runsafterFind, thenafterInitialize, and every record built runsafterInitialize, afterbuild's orcreate'sinit. Both run synchronously, so anasyncone is a type error.record.hasAttribute(name), as Rails'has_attribute?, says whether a record fromselect(...)loaded an attribute. -
#500
51c19f1Thanks @christopherstyles! -Model.noTouching(fn)(#496), as Rails'no_touching: insideArticle.noTouching(async () => { … }), no article is touched, by a comment'sbelongsTo(Article, { touch: true })or by its owntouch(), which writes nothing and resolves tofalse. It covers the Model and those extending it (ApplicationRecord.noTouchingcovers every Model), and only the code it runs, so other requests still touch. A save still sets its ownupdatedAt, andtouchAlland the counters'touchoption still write. LikewithDatabase, it needs Node.js compatibility. -
#505
ad30cc7Thanks @christopherstyles! - The guide's pages stand on their own (#504). Each opens with one sentence saying what it lets you do, and the new Conditions and Through associations pages show the Models their examples use, with each example's imports, and its types on hover. Thellms-full.txtin the package carries the same pages.
@forestfuture/active-record@0.8.1
Patch Changes
-
#492
980f06aThanks @christopherstyles! - Inverse associations (#62). A record loaded through its owner'shasManyorhasOne, by the association, its finders, a Relation narrowed from it, orincludes, has the owner loaded as itsbelongsTo, the same object, soawait post.author()sends no query. Through anautosave: truebelongsTo, saving such a record now also saves the owner's unsaved changes, since the owner is loaded. AbelongsTo's record, read or preloaded, has the owner as its inversehasOne. A record built through a new owner keeps pointing back after saving fills in its foreign key. The inverse is inferred by foreign key, so it's found with aforeignKey:option too; name it withinverseOf: "author"(on an association with ascope:, for one), or turn it off withinverseOf: false. A wronginverseOfisInvalidModelwhen the Model is first used. -
#495
e2d8ed1Thanks @christopherstyles! - Touching records (#50).record.touch()setsupdatedAt, and any datetime attributes named, to now (or{ time }) without a save, then runsafterTouchand the update commit callbacks. A Relation'stouchAll()touches every row it matches in one statement, andincrementColumnanddecrementColumntake{ touch }.
@forestfuture/active-record@0.8.0
Minor Changes
-
#333
bfa9bb6Thanks @christopherstyles! - A batch's writes are prepared in its callback (#332):batch((b) => [b.save(user), b.destroy(post), b.insert(Log, { … }), b.updateAll(Post.where({ … }), { … }), b.deleteAll(user.posts())]), anddb.batchthe same.bhas a method for each write, named as the write is when it runs alone, taking a Model or a Relation first. A Model is written on the batch's database, sodb.model(…)isn't needed insidedb.batch. The callback can't await: one that doesn't return an array, and abused after it has returned, throw aTypeErrorwith nothing sent.Breaking: the array form of
batchanddb.batchis removed, along with theto…methods (toInsert,toInsertAll,toUpsert,toUpsertAll,toUpdateAllandtoDeleteAll, on Relations and as Model statics) and records'toSave()andtoDestroy(). A prepared write no longer hastoSql();onQueryshows what a batch sent. Replacebatch([user.toSave(), Post.where(…).toDeleteAll()])withbatch((b) => [b.save(user), b.deleteAll(Post.where(…))]). -
#394
e688585Thanks @christopherstyles! -binaryattributes and custom types (#20).A
binaryattribute holds bytes as aUint8Array, in aBLOBcolumn on D1 or abyteaone on Postgres. It's assigned aUint8Arrayor anArrayBuffer, and always reads back as a plainUint8Array. A change is found by comparing bytes, so a byte changed in place is saved.where,gtandordercompare bytes in order. A printed record shows<3 bytes of binary data>.active-record schemareadsBLOBandbyteacolumns asbinary, where they were errors, andgwritesname:binaryasBLOBorBYTEA.permitstill refuses a file: assignnew Uint8Array(await file.arrayBuffer()).defineType({ storedAs, cast, serialize, deserialize })makes a custom type, which a spec takes as it takes a type's name:price: money, or{ type: money, null: false }, and a generated Model's override too. Its values are kept asstoredAskeeps its own, so they're read strictly, compared and ordered as that type's are. What itscastordeserializethrows is aTypeErrornaming the Model and attribute, with the type's error as itscause;defineTypethrowsTypeErrorfor an unknownstoredAsor a missing function.isAttributeChangedand the other change methods cast theirfromandtoas a condition's value is cast, sofrom: "2026-01-01"matches adatetime, and a value that can't be cast matches nothing, where it could throw.Breaking:
typeForAttribute(name).serializeis typedstring | number | Uint8Array | null, since abinaryattribute's stored form is bytes. -
#405
a451f78Thanks @christopherstyles! -decimal,dateandtimeattributes (#391).A
decimalholds an exact number as text in one form:"12.50"reads as"12.5". It's assigned decimal text or abigintexactly, or a number at 16 significant digits (0.1 + 0.2is"0.3"). A decimal past a JavaScriptnumber's range ("1e400","1e-400") is refused. Conditions, comparisons andordercompare decimals as numbers, and so donumericalityandcomparison. D1 keeps about 15 significant digits; Postgres'snumerickeeps every one.A
dateholds a day,"2026-01-02", and atimea time of day,"09:30:00"(up to"24:00:00", the end of the day), both as text with no zone. ADateis refused for either, since its day and time depend on the time zone.active-record schemareadsNUMERICandDECIMALcolumns asdecimal, where they were errors, andTIMEastime.gwritesprice:decimal,starts_on:dateandopens_at:time, with=valuedefaults.Breaking:
active-record schemareads aDATEcolumn as adate, where it was adatetime. Override it with"datetime"to keep aDate. On D1, aDATEcolumn adatetimewrote holds2026-01-02T00:00:00.000Z, which adatecan't read; the upgrading guide shows the SQL that keeps each day. ATIMEcolumn, read as astringbefore, reads as"09:30:00". -
#387
450bb89Thanks @christopherstyles! - Enum attributes (#340). Declare one withenum, in an override (status: { enum: ["draft", "published"] }) or indefine, with names stored as text or mapped to integers ({ low: 0, high: 10 }). Its property is typed as the union of its names, an unknown value throwsTypeErrorwhen it's assigned, and a stored value the enum doesn't list reads asnull. Each name gives recordsisPublished()andsaveAsPublished()/saveAsPublishedOrThrow(), and the Modelpublished()andnotPublished()scopes;Post.enumValues("status")gives the names with their stored values.prefix,suffix,scopes: false,instanceMethods: falseandvalidate: truework as Rails' options do.The generated
schema.tsis now adefineSchema({ … })call, which makes a generated Model's enum scopes statics from the start. Runnpx active-record schemato regenerate yours;--checkreports a schema an older version wrote. -
#390
e5fb4d5Thanks @christopherstyles! -active-record schemareads enums from the database (#64). A column whose values a Postgres enum type, or aCHECK (column IN ('open', 'done'))on D1 or Postgres, restricts to a list of strings becomes a generated enum: its spec lists the names, withscopes: falseandinstanceMethods: false, so its type is the union of the names and assigning any other value throwsTypeError. Its Model turns the predicates, setters, and scopes on with an override'senum: true, or drops the enum withenum: false.Regenerating an existing schema narrows such columns to their names, so code that assigned other text to one now throws
TypeError; override the column withenum: falseto keep it a plain string. -
#456
019d1c5Thanks @christopherstyles! - A record built, created, or inserted through ahasManyalways gets its owner's key (#346), as one built through ahasOnealready did. Breaking: a foreign key passed along, as inuser.posts().build({ userId: otherId }), is now replaced by the owner's instead of kept. Build a record for another owner through that owner, or through the Model. -
#373
c169409Thanks @christopherstyles! - AhasOnereplaces its record as Rails does (#40).await user.profile.set(profile)gives the owner another record, andset(null)removes it. On a saved owner,set,buildandcreateremove the old record bydependent::"destroy"destroys it,"delete"deletes it, and otherwise its foreign key is set tonulland it's saved. It's removed in the same atomic batch that writes the new record: at once forsetandcreate, and forbuildwhen the owner is saved. An old record that can't be saved with anullforeign key throwsRecordNotSaved, and nothing is written.Breaking:
buildandcreatethrough a saved owner'shasOneused to leave the old record as it was. Withoutdependent, its foreign key is now set tonull, which aNOT NULLcolumn refuses; setdependent: "destroy"or"delete"to remove it instead. Building twice through an unsaved owner'shasOnenow saves only the last record. -
#364
6c91a98Thanks @christopherstyles! - A new record's changes run from its declared defaults and generated ids (#41), as in Rails:Post.build()holding only defaults isn't changed, and assigning a default's value isn't a change. Inserts still write them. After a create,savedChanges()is what the insert changed plus what the write or the database filled in (a generated key, timestamps), not the defaults the record kept.Breaking: code reading a new record's
changes(),changed(),isChanged()orsavedChanges()no longer sees its kept defaults or generated id.
@forestfuture/active-record@0.7.0
Minor Changes
-
#307
8086f1fThanks @christopherstyles! - The adapters now ship inside@forestfuture/active-record, so an app installs one package. Import what opens D1 from@forestfuture/active-record/d1(connect,withSession,NoSession,d1), and uninstall@forestfuture/d1-record, which gets no new version. The PostgreSQL adapter is@forestfuture/active-record/postgresql(connect,postgresql), with your ownpg;pgand PGlite are optional peer dependencies, so a D1 app installs neither.Every
active-recordcommand now readsactive-record.jsonc, which names each of your databases and its adapter ("DB": { "adapter": "d1" }). Runnpx active-record initto write it: it reads your Wrangler config, and links a JSON Schema your editor completes the file from. Run it again after you add a database to your Wrangler config: it adds the ones the file doesn't name, and leaves the rest as you wrote it. A D1 database's other settings stay in your Wrangler config, and every command notes a D1 database there that the file doesn't name.--adapteris gone from every command butinit, and--confignow namesactive-record.jsonc.Run
npx active-record schemaonce: the generated schema now importsd1from@forestfuture/active-record/d1, and until you regenerate it,schema --checkreports it as out of date. See Upgrading. -
#290
8806626Thanks @christopherstyles! - Theactive-recordcommand now speaks for any adapter. Its help and messages say the database, its binding and its config, and D1's own words (migrations_pattern, the config file) come from D1's plugin.active-record schema --checknow reports a schema as out of date when it was written for another adapter, so a schema written before this release reads as out of date once: runnpx active-record schemato bring it up to date. The console keeps its history in.wrangler/active-record-history; the old.wrangler/d1-record-historyisn't read, so earlier history isn't offered. The command itself needs Node 22.5 or later; on D1 every command still needs 22.13 (23.4 on Node 23), fornode:sqlite, and says so before it starts. A plugin for the command (its interface is@forestfuture/active-record/cli, unstable) reads a schema asynchronously, names the folder for the command's local files, can say why a Node can't run it, and gets the chosen database's migrations folder in place of D1's account.
Patch Changes
-
#287
b6e2d37Thanks @christopherstyles! - The adapter interface (@forestfuture/active-record/adapter, unstable) takes what the PostgreSQL adapter needs: a dialect writes its own placeholders and links keys of different types, a driver can hold a connection for awithDatabasescope, andworkersEnv()tells a Worker from Node. Nothing changes for an app on D1. -
#298
2cb4107Thanks @christopherstyles! -g modelandg migrationname a new migration for the UTC second it's written in (20261108090503_create_products.sql), on D1 too, so migrations written on two branches don't clash. Wrangler orders D1's migrations by their leading number, so files numbered0001_…still run first. The command reads a project'sactive-record.jsonc, which Postgres projects declare their databases in. A plugin for the command (@forestfuture/active-record/cli, unstable) returns a migration's SQL and notes while the command names its file, reads a schema with its database's config entry, and shares the core's helpers for reading tables, migration names and JSON with comments.
@forestfuture/d1-record@0.6.0
Minor Changes
-
#281
febbe8cThanks @christopherstyles! - The command line is nowactive-record, also installed asffar, and comes with@forestfuture/active-record.npx d1-recordis gone: runnpx active-record schema,g model,g migrationandconsoleas before.npx active-record migrateapplies your pending migrations, locally by default, through your project's own Wrangler.--remoteasks you to type the database's name first, and--yesskips that. The generators now suggest it as the next step.- The command finds its adapter from your
package.json. When a project has several installed, choose one with--adapter d1. - Generated schema files now say "Generated by
active-record schema". Their format number went up, soactive-record schema --checkasks you to regenerate them once.
-
#275
992d4e3Thanks @christopherstyles! - Bulk inserts resolve to the rows they wrote, and the base error isActiveRecordError. Both are breaking changes.insert,insertAll,upsertandupsertAllresolve to{ rowsAffected, rows }in place of D1'smeta.rowsholds each written row's primary key, read as its type. Name other attributes withreturning: ["id", "createdAt"], which typesrowstoo, or passreturning: falsefor none. Replacemeta.changeswithrowsAffected. For a one-row insert,rows[0]holds the new row's primary key in place ofmeta.last_row_id.- A statement's result in
db.batchis the same{ rowsAffected, rows }.rowsis empty fortoUpdateAllandtoDeleteAll. D1RecordErroris nowActiveRecordError, with no alias. Rename it ininstanceofchecks.- D1's
metais still on everyonQueryevent, typedD1Meta.
-
#280
41a4c37Thanks @christopherstyles! - The library is now two packages, both breaking changes.@forestfuture/active-recordis the core, and@forestfuture/d1-recordis its D1 adapter. Install both. The guide's Upgrading to 0.6 walks through the move.- Import Models, Relations, validations, callbacks, associations,
withDatabase,batchand the error classes from@forestfuture/active-record. Importconnect,withSession,NoSession,d1, and D1'sQueryEventandQueryListener, from@forestfuture/d1-record.d1-recordre-exports nothing of the core. - The generated schema names its adapter:
adapter: d1({ binding: "DB" })replacesbinding: "DB". Runnpx active-record schemato regenerate it. toSql()on a Model with no generated schema, outsidewithDatabaseand with nodb, throwsNoDatabase, since nothing says which database's SQL to write.- The agent skill is now
active-record, in@forestfuture/active-record, which shipsllms-full.txttoo.
- Import Models, Relations, validations, callbacks, associations,
Patch Changes
- #273
eb0cf85Thanks @christopherstyles! - A bookmark D1 rejects no longer passes for a constraint failure. A forged cookie could make a request's first statement throwRecordNotUniqueor another constraint error, and now starts the Session again. A bookmark given toconnectthrows D1's error. - Updated dependencies [
febbe8c,41a4c37]:- @forestfuture/active-record@0.6.0
@forestfuture/active-record@0.6.0
Minor Changes
-
#281
febbe8cThanks @christopherstyles! - The command line is nowactive-record, also installed asffar, and comes with@forestfuture/active-record.npx d1-recordis gone: runnpx active-record schema,g model,g migrationandconsoleas before.npx active-record migrateapplies your pending migrations, locally by default, through your project's own Wrangler.--remoteasks you to type the database's name first, and--yesskips that. The generators now suggest it as the next step.- The command finds its adapter from your
package.json. When a project has several installed, choose one with--adapter d1. - Generated schema files now say "Generated by
active-record schema". Their format number went up, soactive-record schema --checkasks you to regenerate them once.
-
#280
41a4c37Thanks @christopherstyles! - The library is now two packages, both breaking changes.@forestfuture/active-recordis the core, and@forestfuture/d1-recordis its D1 adapter. Install both. The guide's Upgrading to 0.6 walks through the move.- Import Models, Relations, validations, callbacks, associations,
withDatabase,batchand the error classes from@forestfuture/active-record. Importconnect,withSession,NoSession,d1, and D1'sQueryEventandQueryListener, from@forestfuture/d1-record.d1-recordre-exports nothing of the core. - The generated schema names its adapter:
adapter: d1({ binding: "DB" })replacesbinding: "DB". Runnpx active-record schemato regenerate it. toSql()on a Model with no generated schema, outsidewithDatabaseand with nodb, throwsNoDatabase, since nothing says which database's SQL to write.- The agent skill is now
active-record, in@forestfuture/active-record, which shipsllms-full.txttoo.
- Import Models, Relations, validations, callbacks, associations,
The core was part of @forestfuture/d1-record before 0.6: its history up to 0.5 is in packages/d1-record/CHANGELOG.md.
@forestfuture/d1-record@0.5.1
Patch Changes
-
#252
ebf0bf7Thanks @christopherstyles! -exists(),isEmpty()andhasAny()now give the right answer afterdistinct()with an offset.Post.select("title").distinct().offset(1).exists()wasfalseeven whentoArray()returned records, because every match counted as one row and the offset skipped it. -
#257
2163b15Thanks @christopherstyles! - The agent skill no longer sends agents to web pages. They read only thellms-full.txtshipped in the package, which matches the installed version.