SurrealDB SDK for JavaScript
APACHE-2.0 License
Bot releases are hidden (Show)
Published by kearfy 5 months ago
Full Changelog: https://github.com/surrealdb/surrealdb.js/compare/v1.0.0-beta.7...v1.0.0-beta.8
Published by kearfy 5 months ago
run
and relate
method by @kearfy in https://github.com/surrealdb/surrealdb.js/pull/264
Full Changelog: https://github.com/surrealdb/surrealdb.js/compare/v1.0.0-beta.6...v1.0.0-beta.7
Published by kearfy 5 months ago
toJSON
and StringRecordId
by @kearfy in https://github.com/surrealdb/surrealdb.js/pull/256
jsonify()
method by @kearfy in https://github.com/surrealdb/surrealdb.js/pull/259
Full Changelog: https://github.com/surrealdb/surrealdb.js/compare/v1.0.0-beta.5...v1.0.0-beta.6
Published by kearfy 6 months ago
Full Changelog: https://github.com/surrealdb/surrealdb.js/compare/v1.0.0-beta.4...v1.0.0-beta.5
Published by kearfy 6 months ago
Full Changelog: https://github.com/surrealdb/surrealdb.js/compare/v1.0.0-beta.3...v1.0.0-beta.4
Published by kearfy 6 months ago
Full Changelog: https://github.com/surrealdb/surrealdb.js/compare/v1.0.0-beta.2...v1.0.0-beta.3
Published by kearfy 6 months ago
Full Changelog: https://github.com/surrealdb/surrealdb.js/compare/v1.0.0-beta.1...v1.0.0-beta.2
Published by kearfy 6 months ago
Full Changelog: https://github.com/surrealdb/surrealdb.js/compare/v0.11.1...v1.0.0-beta.1
Published by kearfy 6 months ago
surrealql()
by @oliver-oloughlin in https://github.com/surrealdb/surrealdb.js/pull/222
Full Changelog: https://github.com/surrealdb/surrealdb.js/compare/v0.11.0...v0.11.1
Published by kearfy 12 months ago
.query()
methodTo further align our JS landscape, the current .query()
method is renamed to .query_raw()
, and a new and simplified .query()
method is introduced. This new method either throws an error or gives back an array of response values.
await db.query<boolean, number>(`true; 123`);
// [true, 123]
// This would previously be an array with query response objects, containing the result.
await db.query(`THROW "some error"`);
// Throws: "An error occurred: some error"
PreparedQuery
class which can be passed to the .query()
and .query_raw()
methods.surrealql
(and surql
as a shortcut) function which can be used as a tagged template literal.const name = "John Doe";
const age = 44;
// With PreparedQuery
const query = new PreparedQuery(
/* surql */`RETURN $name; RETURN $age`,
{ name, age }
);
const prepared = await db.query(query);
// With a tagged template literal
const templated = await db.query(
surrealql`RETURN ${name}; RETURN ${age}`
);
Full Changelog: https://github.com/surrealdb/surrealdb.js/compare/v0.10.1...v0.11.0
Published by kearfy 12 months ago
Full Changelog: https://github.com/surrealdb/surrealdb.js/compare/v0.10.0...v0.10.1
Published by kearfy 12 months ago
ns
/db
/sc
/user
/pass
renamed to namespace
/database
/scope
/username
/password
This change was introduced to better align the JS SDK with the Rust SDK and the rest of our JavaScript landscape
await db.use({
ns: 'test',
db: 'test'
});
await db.signin({
ns: 'test',
db: 'test',
user: 'root',
pass: 'root'
});
await db.signin({
ns: 'test',
db: 'test',
sc: 'user',
...
});
await db.use({
namespace: 'test',
database: 'test'
});
await db.signin({
namespace: 'test',
database: 'test',
username: 'root',
password: 'root'
});
await db.signin({
namespace: 'test',
database: 'test',
scope: 'user',
...
});
.authenticate()
is tested for both scope and root users by @kearfy in https://github.com/surrealdb/surrealdb.js/pull/182
boolean
to RawQueryResult
by @kearfy in https://github.com/surrealdb/surrealdb.js/pull/183
Full Changelog: https://github.com/surrealdb/surrealdb.js/compare/v0.9.1...v0.10.0
Published by kearfy about 1 year ago
Full Changelog: https://github.com/surrealdb/surrealdb.js/compare/v0.9.0...v0.9.1
Published by kearfy about 1 year ago
.connect()
function (which can be awaited by the way!).authenticate()
now returns a boolean indicating success or not success. Be aware that authentication errors will still result in an error being thrown!Full Changelog: https://github.com/surrealdb/surrealdb.js/compare/v0.8.4...v0.9.0
Published by kearfy about 1 year ago
.query()
method for the experimental HTTP strategy.insert()
method to allow for bulk record insertiondiff
to the .live()
method, which allows you to receive back notifications in the form of JSON Patches.As most of this is only available with the nightly version of SurrealDB, I would like to link the nightly docs (all though a bit buggy here and there) aswell: https://deploy-preview-197--coruscating-puppy-14fc4b.netlify.app/
.insert()
method by @kearfy in https://github.com/surrealdb/surrealdb.js/pull/150
.live()
diff option by @kearfy in https://github.com/surrealdb/surrealdb.js/pull/151
FEATURE_TEMPLATE
-> ISSUE_TEMPLATE
by @kearfy in https://github.com/surrealdb/surrealdb.js/pull/154
.insert()
by @kearfy in https://github.com/surrealdb/surrealdb.js/pull/161
Full Changelog: https://github.com/surrealdb/surrealdb.js/compare/v0.8.3...v0.8.4
Published by kearfy over 1 year ago
The NS
and DB
properties are now optional in signin/signup functions for Scope authentication. They are still required for namespace and database user authentication!
Full Changelog: https://github.com/surrealdb/surrealdb.js/compare/v0.8.2...v0.8.3
Published by kearfy over 1 year ago
.info()
should await ready state by @kearfy in https://github.com/surrealdb/surrealdb.js/pull/137
Full Changelog: https://github.com/surrealdb/surrealdb.js/compare/v0.8.1...v0.8.2
Published by kearfy over 1 year ago
.info()
method for the websocket strategy
SELECT * FROM $auth
Full Changelog: https://github.com/surrealdb/surrealdb.js/compare/v0.8.0...v0.8.1
Published by kearfy over 1 year ago
Breaking: Fix typings for .select()
, .create()
, .update()
, .merge()
, .patch()
, .delete()
.select()
methods now returns an array instead of a single item..change()
method is renamed to .merge()
..modify()
method is renamed to .patch()
.undefined
.Breaking: The .use()
function now accepts an object as an argument .use({ ns, db })
.
You can now pass an auth property to the second argument of the constructor and connect functions. This can be a token string or an object you would pass to the .signin()
function.
You can now pass a pair of { ns, db }
to the second argument of the constructor and connect functions.
The auth state and ns/db combo will now be remembered after a possible WebSocket disconnect and will automatically be restored.
Added back the Live Queries implementation (read down below)
Start a live query
const uuid = await surreal.live<{
id: string;
prop: number;
}>("query...", (data) => {
if (data.action === 'CLOSE") return;
console.log(data.result);
});
Register another listener for an LQ
await surreal.listenLive<{
id: string;
prop: number;
}>("uuid...", (data) => {
if (data.action === 'CLOSE") return;
console.log("Second listener! ", data.result);
});
Kill a LQ
await surreal.kill("uuid...");
type close = {
action: "CLOSE",
detail: "SOCKET_CLOSED" | "QUERY_KILLED"
};
type create = {
action: "CREATE";
result: Record<string, unknown>; // Generic type that was passed, always extends default type
};
type update = {
action: "UPDATE";
result: Record<string, unknown>; // Generic type that was passed, always extends default type
};
type delete = {
action: "DELETE";
result: Record<string, unknown>; // Generic type that was passed, always extends default type
};
.select()
, .create()
, .update()
, .merge()
, .patch()
, .delete()
by @kearfy in https://github.com/surrealdb/surrealdb.js/pull/104
Full Changelog: https://github.com/surrealdb/surrealdb.js/compare/v0.7.3...v0.8.0 (might not completely align with above notes, v0.7.3 was a little bit quirky)
Published by kearfy over 1 year ago
As pointed out by @amaster507, the v0.7.2 release rightfully contained a breaking change by switching out the isomorphic-ws
package for unws
. I inspected the two packages before the release and concluded that their behaviour was the same, besides unws
having fixed some issues the isomorphic-ws
was experiencing.
What I did not notice was that the export for commonjs projects was done with the export
keyword instead of module.exports
. I opened a PR to fix this which got merged. I tested once again to conclude that this fixes the issue that developers working on a commonjs
were experiencing, which now technically makes this a patch release based on v0.7.1.
Full Changelog: https://github.com/surrealdb/surrealdb.js/compare/v0.7.2...v0.7.3