I want to use the cassandra database with nestJS, and I find some diffuclty.
Please if you can help me.
I've created a feature request on TypeORM for Cassandra some time ago: https://github.com/typeorm/typeorm/issues/1626 . Feel free to upvote the feature there
I don't think your issue directly affects NestJS.
@weeco is right.
PS. Upvoted!
Putting this here too in case anyone else looking for Cassandra support in Nest finds this ticket. I definitely intend to make sure that the Repository classes exposed by my library are injectable inside the context of a Nest app.
I've been working on a TypeScript library for Cassandra over the last week or so (very early days) but progress is coming along really quickly. https://github.com/WonderPanda/NoSequel
Should be ready for some beta testing within the next week which will cover functionality for table schema generation, intelligent querying, automatic mapping between db rows and entities, deletion, etc.
If you feel like popping over and opening up some issues for the "need to have" functionality you're looking for in a library I'd definitely take a look at bringing that in.
I want to use the cassandra database with nestJS, and I find some diffuclty.
Please if you can help me.
I created NestJS module nestjs-express-cassandra. It is based on express-cassandra orm package.
@ifaim looks very good - are you using it in a production environment?
We are using nestjs-express-cassandra in production several of our micro-service without Elassandra support.
@ifaim, we are using your package. I have a question, regarding exposing cassandra logging. How am i able to get the instance of the cassandra client. We're instantiating by using forRootAsync.
ExpressCassandraModule.forRootAsync({
imports: [DbConnectModule],
useExisting: DbConnectService
})
All of the examples I see are doing it directly with the driver
var client = new cassandra.Client({contactPoints: ['localhost']});
client.on('log', function(level, className, message, furtherInfo) {
console.log('log event: %s -- %s', level, message);
});
Hey,
There is two way you can do that.
Injecting express-cassandra connection: Library already expose a
decorator called @InjectConnection(), this will inject express-cassandra
connection to module or service, then get cassandra-driver instance:
@Module({
imports: [
ExpressCassandraModule.forRootAsync({
imports: [ConfigModule],
useExisting: CassandraConfig,
}),
],
})
export class ApiModule {
constructor(
@InjectConnection()
private readonly connection,
) {
const client = connection.orm._client;
client.on('log', (level, className, message, furtherInfo) => {
console.log(level, className, message, furtherInfo);
});
}
}
This is bit of messy, but I recommand to use it.
Get client instance from repository: You could get cassandra-driver
instance from repository model.
@Injectable()
export class SomeService implements OnModuleInit {
async onModuleInit() {
const model = (this.userRepo as any).model;
const client = await model.get_cql_clientAsync();
client.on('log', (level, className, message, furtherInfo) => {
console.log(level, className, message, furtherInfo);
});
}
constructor(
@InjectRepository(UserEntity) private readonly userRepo: Repository
) {}
}
I hope this help you.
On Wed, Jul 17, 2019 at 11:13 PM amnporter notifications@github.com wrote:
@ifaim https://github.com/ifaim, we are using your package. I have a
question, regarding exposing cassandra logging. How am i able to get the
instance of the cassandra client. We're instantiating by using forRootAsync.ExpressCassandraModule.forRootAsync({
imports: [DbConnectModule],
useExisting: DbConnectService
})All of the examples I see are doing it directly with the driver
var client = new cassandra.Client({contactPoints: ['localhost']});
client.on('log', function(level, className, message, furtherInfo) {
console.log('log event: %s -- %s', level, message);
});—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/nestjs/nest/issues/542?email_source=notifications&email_token=ABIXIKK4G3BH37S5IDKW6ZLP75HMLA5CNFSM4EY22HC2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2FLK3Q#issuecomment-512406894,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABIXIKIEY4HPCW4TO47E6LDP75HMLANCNFSM4EY22HCQ
.
--
Best regards,
Md. Fahim Rahman.
@ifaim, thanks for ur response. I actually got it working last night by using the @InjectConnection()
method you described above in our service. Now that say it can be done at the module level, I will try that. Thanks for your prompt attention.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
I've created a feature request on TypeORM for Cassandra some time ago: https://github.com/typeorm/typeorm/issues/1626 . Feel free to upvote the feature there
I don't think your issue directly affects NestJS.