- Delegate connection logic to surrealdb.js
- Original implementations are still available as
LegacyCirqlStatefulandLegacyCirqlStateless - These will be removed in a future version
- Original implementations are still available as
- Added
cirql.query()to execute raw queries - Export
surqltemplate literal function- Useful for syntax highlighting when available
- Escapes interpolated values as JSON
- Update connection logic with additional checks and fixes
- Add support for patches in update queries
- Record links are now validated opposed to being converted to JSON strings
- This is to ensure compatibility with changes in SurrealDB beta 9
- Should not break existing code, however the internal regex may not cover all valid formats yet
- The query timeout in stateful connections can now be customized using the
queryTimeoutoption, specified in milliseconds
- Improved the generation of
WHEREclauses- Also fixes edge cases where parenthesis were generated incorrectly
- Improved the internal implementation of
countqueries- Should have increased performance on large tables
- Fixed
countreturning null instead if 0
- When selecting from a record start and limit are now ignored
- The behavior of
.where()and.setAll()has been altered to work in a more consistent and expected wayundefinedvalues are skippednullvalues are converted to NONE, which in surreal represents missing valuesraw('null')can be used to use JavaScript-like null values
.setAll()now automatically inserts an equals sign for raw values not starting with += or -= This means you no longer need to wrap all raw values witheq()going forward- Implemented some initial unit tests
- Fixed passing null to setAll throwing an error
- Fixed dates not being included in CREATE and UPDATE queries
- Add convenience schema functions to query writers
withSchema(object)as shortcut for.with(z.object(object))withAny()as shortcut for.with(z.any())
- Fixed schemaless queries being allowed
- Queries should always have a shema
- You can explicitly opt-out by using
.with(z.any())
- Fix return type of execute() something incorrectly being any
- Allow manually specifying type for count .where()
- Schemas can now be defined directly on the query
- This is done using
QueryWriter.with() - Specifying the schema like this provides type completion for additional function including
.set(),.where(), and more - The classic way of specifying the schema is still valid and required if the query contains no schema
- This is done using
- Allow specifying sub queries in
.where()- Achieved by specifying a
QUERYproperty with a two value array - The first value is the query writer
- The second value is a raw query value
- Can be used in conjunction with AND and OR
- Achieved by specifying a
- Removed deprecated
timeNow()function, you should instead usetime.now() - Removed deprecated
relateRecords()function, you should instead userelateRelation()
- Fixed issue where certain values could not be used as
SurrealValue
- Added
select().addQuery(alias, writer)to add inner queries to selections - Support params in stateless queries
- Renamed and deprecated certain functions in favor of new approaches
select().fromRecord(),delRecord(),countRecord(), andupdateRecord()now support passing just a record id- The id will be JSON stringified to escape any potential invalid content
- Add new
andfunction to the select query writer to dynamically append projections
- Improve RecordRelation type to allow SurrealValue and omitting
fromTableandtoTable
- Date objects are now automaticaly converted to ISO strings in more situations
- Expose query writer state publicly as
writer._state - Allow raw values to be passed to more functions
- This includes targets for
create(),update(),delete(), etc. - Mostly a convenience feature, should make the API more consistent
- This includes targets for
- For compatibility with the upcoming beta 9 and latest nightly builds
select()andcount()now make use ofGROUP ALLinstead ofGROUP BY ALL- This may cause issues in codebases using beta 8
- Added
RecordSchemaandEdgeSchemaexports- Can be used instead of
z.object()to extend your schemas usingRecordSchema.extend({}) RecordSchemadefines theidfield present on all recordsEdgeSchemadefines theid,in, andoutfields present on all edge records
- Can be used instead of
- Overhaul authentication support
- Credentials are now optional when creating a new
Cirqlinstance - Added
cirql.signIn()to authenticate and return the session token - Added
cirql.signUp()to register a new account and return the session token - Added
cirql.signOut()to sign out of the current account - Full support for token authentication, allowing you to persist sessions
- This is not available yet for stateless connections
- Credentials are now optional when creating a new
- The
RawQuerytype is now exported
- Added raw helper function for all
typefunctions- Namespaced under
type, e.g.type.decimal()
- Namespaced under
- Deprecated
timeNow()as it has been replaced withtime.now()
- Added
paramfunction as shortcut forraw('$' + name) - Allow query writers to be passed to operators
- Added
parseQueriesutility function
- Added
updateRelationquery writer - Added
countRelationquery writer - Added
fromRelationto select query writer
- Relate query writers now require a schema
- The benefit is that created edge records are now returned
- Validation can now be disabled per query by setting the
validateoption to false- This is a potentially dangerous action as malformed records will not match your typings, potentially introducing bugs further down in your codebase
- You should only disable validation if you are manually validating records
- Improved error handling for query failures in batch requests
- All errors are now printed out at once
- The error object now contains a
errorsproperty which is an array of all errors
- Deprecated
singleoption as this behavior is now performed automatically - Added
delRelationquery writer
- Added
countRecordquery writer- Primarily useful in conjunction with
.where()to test whether a specific record matches a condition.
- Primarily useful in conjunction with
- Added
singleoption for queries which expect a single response such asINFO FOR DB
- Removed the classic API
- This was deprecated in 0.2.0
- Fixed missing TypeScript definitions
- Implemented query writer for
LET - Added
cirql.ready()for awaiting stateful connection opening - Fixed some issues in the new API
- Completely rewritten the API to be more consistent and easier to use
- Original API is still available but marked as deprecated
- Will be removed in a future version
- Added special query writer
query()for wrapping raw query strings- This is the new and only way to send raw query strings
- Added
cirql.execute(),cirql.batch(), andcirql.transaction()which are used to execute all queries - Added more functions to existing query writers
- We still intend to implement writers for
LETandIFsoon. You can usequery()for now.
- We still intend to implement writers for
- New API provides better runtime checking of queries and supplied schemas
- Rewritten README to reflect new API
- Schemas are required for all query functions again
- This fits better with the design goals of Cirql
- You can still "opt-out" by setting schema to
z.any()
- Export convinience
timeNow()function
- Ignore
undefinedvalues in set fields
- Convert
nulltoNONEwhen passed to SET query fields- This allows unsetting properties using
cirql.update()
- This allows unsetting properties using
- Implemented remaining query writers for
CREATE,UPDATE,DELETE, andRELATE - Restricted
queryOneandqueryManyto only acceptSelectQueryWriterinstead of all writers - Delete query record id is now optional
- Update expected types for
wherefields - Improved query writer parameters
- Most functions now accept varargs
orderBycan now be passed a single field and ordering
- Improve
errorandcloseevents - Improve internal logic
- Avoid useage of CustomEvent for
errorevent as node LTS does not support it- Custom event is now emitted containing
codeandreasonproperties
- Custom event is now emitted containing
- Fixed delete operations failing
- Delete, relate, and let queries now return
Promise<undefined>- This makes the typings for arrays returned by chaning more accurate
- Added support for stateless queries
- Use the new
CirqlStatelessclass - Same API as the main stateful
Cirqlclass
- Use the new
- Added query function for LET statement
- Added query function for IF ELSE statement
- Refactored authentication
- Now supports scope, namespace, database, and token authentication
- Refactored AND & OR behavior
- Now allows for more combinations than before
- Allow array add and remove in update queries
- Added support for query writers
- Added retry functionality
- Refactored some functions
- Basic functionality only