question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom serializer and multiple models

See original GitHub issue

Hi!

I use couch db database with multiple models from F#, I was wondering:

  1. How to add work with a different serializer (because F# serialized bit weird)?
  2. How to work with different documents in the same db?

I assume I can use diff “databases” that are the same but with different TSource.:

var rebels = client.GetDatabase<Rebel>("StarWars");
var clones = client.GetDatabase<Clone>("StarWars");

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
matteobortolazzocommented, Mar 9, 2021

V3.0.0 released

1reaction
matteobortolazzocommented, Mar 4, 2021

@panoukos41 doing a non-generic version of GetDatabase is not possible, you need types to call LINQ methods, also because on the method called, the type changes, for example, when you call Select or Average.

What I did instead is:

  • injecting the discriminator as a string at database creation
  • add an internal discriminator field in CouchDocument
  • set the field on document creation
  • add a Where(d => d.Discriminator == Value) to the LINQ call
  • add configuration support in the context so that:
    • the discriminator is set only if multiple CouchDocuments target the same database
    • the value of the discriminator is the name of the type

This way everything is automatic and safe.

Everything is in the dev branch if you want to test and give me your feedback couchdb-net/tree/dev#database-splitting

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to serialize multiple model object?
You use a subserializer, so: class Task_extendedSerializer(serializers.ModelSerializer): class Meta: model = Task_extended fields ...
Read more >
DjangoRestMultipleModels — DjangoRestMultipleModels 2.1 ...
Django Rest Framework provides some incredible tools for serializing data, but sometimes you need to combine many serializers and/or models into a single...
Read more >
Django : Serialize multiple models and send all in one json ...
Django : Serialize multiple models and send all in one json response django rest framework [ Beautify Your Computer ...
Read more >
Django REST Framework API Serializer Multiple Models Json ...
djangorestframework #multiplemodelsoneview Django REST Framework API Serializer Multiple Models Json Response Display multiple models in a ...
Read more >
Serializing multiple models
You can specify serializers to user for model relationships. class UserProfileSerializer(serializers.ModelSerializer):. class Meta: model = UserProfile. fields ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found