Comments (9)
@MRdgz I just tested the factory should only called once,
also the model should be passed as the second arg, so please try this example if this works for u
export const GameSchemaDef = {
id: String,
state: String,
}
@Module({
imports: [
DynamooseModule.forFeatureAsync([
{
name: 'User',
useFactory: () => UserSchema,
},
{
name: 'Game',
useFactory: (_, model) => new Schema({ ...GameSchemaDef, user: model }),
inject: ['UserModel'],
},
]),
]})
from nestjs-dynamoose.
Sorry for miss-leading message, but the last example is worked for me
from nestjs-dynamoose.
@MRdgz i don't know this will work or not, but u could have a try.
import { model, Schema, THIS } from 'dynamoose';
export const UserSchema = new Schema({
id: String,
name: String,
parent: THIS,
});
export const GameSchema = new Schema({
id: String,
state: String,
user: model('User', UserSchema),
});
import { UserSchema, GameSchema } from './schema'
@Module({
imports: [
DynamooseModule.forFeature([
{
name: 'User',
schema: UserSchema,
},
{
name: 'Game',
schema: GameSchema,
},
]),
],
...
})
from nestjs-dynamoose.
Thanks, I'll let you know if this works!
from nestjs-dynamoose.
It didn't work. At compile time, an UnhandledPromiseRejectionWarning: ConfigError: Missing region in config
warning is shown. If I attempt to save anyways, it does store into the game table as
{
"id": 1,
"state": "loss",
"user" : {
"id": 33,
}
}
But when fetching the record and executing the await game.populate()
it just hangs.
from nestjs-dynamoose.
I've also tried the following with GameSchema(model).getSchema()
returning a schema instance. Using this method. It no longer generates the warning from above but says that user
is an unknown property when trying to store new information. I did notice that during compile, the factory is running twice. The first has model
as undefined, and the second time model
is actually defined.
@Module({
imports: [
DynamooseModule.forFeatureAsync([
{
name: 'User',
useFactory: () => UserSchema,
},
{
name: 'Game',
useFactory: (model) => new GameSchema(model).getSchema(),
inject: ['UserModel'],
},
]),
]})
from nestjs-dynamoose.
@hardyscc @MRdgz will join here. Have same problem right now. I tried both solutions, and getting same error as above ConfigError: Missing region in config
from nestjs-dynamoose.
Thank you, the solution above also worked for me! I will close the issue now! 😄
from nestjs-dynamoose.
Thank you, the solution above also worked for me! I will close the issue now! 😄
@MRdgz do you have working sample? I tried the same but got error at compile time Type 'SchemaSettings' is missing the following properties from type 'AttributeDefinition[]
from nestjs-dynamoose.
Related Issues (20)
- Feature for passing a custom dynamoose ddb in module options HOT 2
- Support for schema property "useDocumentTypes" HOT 1
- DAX support HOT 10
- Dynamoose v3 support HOT 2
- Support for AWS Web identity token credentials ? HOT 1
- NestJS v9 Support HOT 4
- Dynamoose AWS IAM ROLE -> CredentialsError: Missing credentials in config HOT 1
- Dynamically configuring DynamoDB table names? HOT 5
- Endpoint URL must be a string, got object HOT 4
- Connect to DynamoDB using credential-providers HOT 5
- The DYNAMOOSE_MODULE_OPTIONS looks unnecessary in dynamoose-core.module.ts` HOT 1
- ForFeatureAsync has weird interface HOT 10
- DynamooseOptionsFactory does not inject dependencies when using useClass HOT 4
- Breaking change HOT 10
- Breaking API/dependency changes HOT 1
- throw built-in 404 when resource not found HOT 2
- update nestjs dependency to v10 HOT 1
- Adding migration HOT 1
- Bug: TransactionSupport not recognizing table name with "prefix" and "suffix" in nestjs-dynamoose HOT 1
- Config with unit test HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nestjs-dynamoose.