30 lines
734 B
TypeScript
30 lines
734 B
TypeScript
import Neode from 'neode';
|
|
import { useConfig } from '@abearxiong/use-config';
|
|
|
|
type NeodeConfig = {
|
|
uri: string;
|
|
username: string;
|
|
password: string;
|
|
};
|
|
const { neo4j } = useConfig<{ neo4j: NeodeConfig }>('neo4j');
|
|
|
|
const { uri, username, password } = neo4j;
|
|
// 设置连接配置
|
|
// const neode = new Neode('bolt://localhost:7687', 'neo4j', 'your_password');
|
|
export const neode = new Neode(uri, username, password);
|
|
|
|
const testConnect = async () => {
|
|
// 连接成功
|
|
// 尝试执行简单的 Cypher 查询以测试连接
|
|
neode
|
|
.cypher('RETURN 1', {})
|
|
.then(() => {
|
|
console.log('connect neo4j success');
|
|
})
|
|
.catch((err) => {
|
|
console.error('Failed to connect:', err);
|
|
});
|
|
};
|
|
|
|
testConnect();
|