- Delegate connection logic to surrealdb.js
- Original implementations are still available as
LegacyCirqlStateful
andLegacyCirqlStateless
- These will be removed in a future version
- Original implementations are still available as
- Added
cirql.query()
to execute raw queries - Export
surql
template 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
queryTimeout
option, specified in milliseconds
- Improved the generation of
WHERE
clauses- Also fixes edge cases where parenthesis were generated incorrectly
- Improved the internal implementation of
count
queries- Should have increased performance on large tables
- Fixed
count
returning 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 wayundefined
values are skippednull
values 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
QUERY
property 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
and
function to the select query writer to dynamically append projections
- Improve RecordRelation type to allow SurrealValue and omitting
fromTable
andtoTable
- 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 ALL
instead ofGROUP BY ALL
- This may cause issues in codebases using beta 8
- Added
RecordSchema
andEdgeSchema
exports- Can be used instead of
z.object()
to extend your schemas usingRecordSchema.extend({})
RecordSchema
defines theid
field present on all recordsEdgeSchema
defines theid
,in
, andout
fields present on all edge records
- Can be used instead of
- Overhaul authentication support
- Credentials are now optional when creating a new
Cirql
instance - 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
RawQuery
type is now exported
- Added raw helper function for all
type
functions- Namespaced under
type
, e.g.type.decimal()
- Namespaced under
- Deprecated
timeNow()
as it has been replaced withtime.now()
- Added
param
function as shortcut forraw('$' + name)
- Allow query writers to be passed to operators
- Added
parseQueries
utility function
- Added
updateRelation
query writer - Added
countRelation
query writer - Added
fromRelation
to 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
validate
option 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
errors
property which is an array of all errors
- Deprecated
single
option as this behavior is now performed automatically - Added
delRelation
query writer
- Added
countRecord
query writer- Primarily useful in conjunction with
.where()
to test whether a specific record matches a condition.
- Primarily useful in conjunction with
- Added
single
option 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
LET
andIF
soon. 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
undefined
values in set fields
- Convert
null
toNONE
when 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
queryOne
andqueryMany
to only acceptSelectQueryWriter
instead of all writers - Delete query record id is now optional
- Update expected types for
where
fields - Improved query writer parameters
- Most functions now accept varargs
orderBy
can now be passed a single field and ordering
- Improve
error
andclose
events - Improve internal logic
- Avoid useage of CustomEvent for
error
event as node LTS does not support it- Custom event is now emitted containing
code
andreason
properties
- 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
CirqlStateless
class - Same API as the main stateful
Cirql
class
- 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