You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The documentation for the Deno library suggests that db.select(thing) can be used with either a table or specific record, however when passing a record Id it always fails with the following error:
RecordError: Record not found: department:40r67eog7lini8rorbr5
at Surreal.#output (https://deno.land/x/surrealdb@v0.5.0/src/index.ts:694:9)
at Surreal.<anonymous> (https://deno.land/x/surrealdb@v0.5.0/src/index.ts:442:19)
at Surreal.f (https://deno.land/x/surrealdb@v0.5.0/src/classes/emitter.ts:26:9)
at https://deno.land/x/surrealdb@v0.5.0/src/classes/emitter.ts:33:10
at Array.forEach (<anonymous>)
at Surreal.emit (https://deno.land/x/surrealdb@v0.5.0/src/classes/emitter.ts:32:20)
at Socket.<anonymous> (https://deno.land/x/surrealdb@v0.5.0/src/index.ts:222:17)
at https://deno.land/x/surrealdb@v0.5.0/src/classes/emitter.ts:33:10
at Array.forEach (<anonymous>)
at Socket.emit (https://deno.land/x/surrealdb@v0.5.0/src/classes/emitter.ts:32:20)
I have also tried running the RPC commands directly on the server using Insomnia which behaves as expected returning the single record when an Id is used as the parameter for select.
There is also a workaround using db.query() but its a bit clunkier.
Steps to reproduce
Create and configure db instance:
SurrealDbmanager.ts
export class SurrealDbManager{
public static instance: Surreal;
private constructor() {}
public static async SetupDb(url: string): Promise<Surreal> {
try {
console.log("Setting up db");
this.instance = new Surreal(url);
await this.instance.signin({
user: 'root',
pass: 'root',
});
await this.instance.use('opsys', 'dashboard')
return this.instance;
} catch (error) {
logger.error(error);
throw error;
}
}
}
index.ts export const db = await SurrealDbManager.SetupDb('http://10.88.10.27:8000/rpc');
Call Create() and make note of the generated id.
Call GetAll() and confirm the new record exists.
Attempt to retrieve the single record with GetById() using the id of the newly created record
DepartmentRepository.ts
import { db } from "../index.ts";
import { Department } from "../db/models/Department.ts";
export class DepartmentRepository{
static async GetAll(): Promise<Department[]>{
const departments = await db.select<Department>("departments");
return departments;
}
static async GetById(id: string): Promise<Department>{
const department = await db.select<Department>(id);
return department[0];
}
static async Create(department: Department): Promise<Department> {
const newDepartmentRecord = await db.create<Department>(
'departments',
department,
);
console.log(newDepartmentRecord);
return newDepartmentRecord;
}
}
Expected behaviour
db.select() should be returning the single record with the specified Id rather than generating an error.
SurrealDB version
1.0.0-beta.9+20230402.5eafebd for linux on x86_64
Contact Details
Is there an existing issue for this?
I have searched the existing issues
Code of Conduct
I agree to follow this project's Code of Conduct
The text was updated successfully, but these errors were encountered:
Hey @frownieebrownie, thanks for this! We're working on a fix in #78 which should be merged soon! After that we'll deploy the fix in an update. Please note that this is an issue purely in the client library, the actual request get's processed just fine. (read, when you update a specific record then you will get back a permission error, whilst it was updated just fine)
@kearfy Amazing. I did notice that could I make the RPC request manually and it worked just fine. Apologies, I should have made the issue on the JS repo rather than here.
Describe the bug
The documentation for the Deno library suggests that
db.select(thing)
can be used with either a table or specific record, however when passing a record Id it always fails with the following error:I have also tried running the RPC commands directly on the server using Insomnia which behaves as expected returning the single record when an Id is used as the parameter for select.
There is also a workaround using
db.query()
but its a bit clunkier.Steps to reproduce
SurrealDbmanager.ts
index.ts
export const db = await SurrealDbManager.SetupDb('http://10.88.10.27:8000/rpc');
Create()
and make note of the generated id.GetAll()
and confirm the new record exists.GetById()
using the id of the newly created recordDepartmentRepository.ts
Expected behaviour
db.select()
should be returning the single record with the specified Id rather than generating an error.SurrealDB version
1.0.0-beta.9+20230402.5eafebd for linux on x86_64
Contact Details
Is there an existing issue for this?
Code of Conduct
The text was updated successfully, but these errors were encountered: