Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 08 08:18
    MikeGoldsmith commented #275
  • Oct 08 08:18
    MikeGoldsmith commented #274
  • Oct 07 14:11
    MikeGoldsmith closed #268
  • Oct 07 14:11
    MikeGoldsmith commented #268
  • Oct 07 13:20
    bVanHertum commented #268
  • Oct 07 09:48
    MikeGoldsmith commented #268
  • Oct 07 09:44
    bVanHertum commented #268
  • Oct 07 09:23
    MikeGoldsmith commented #268
  • Oct 07 09:23

    MikeGoldsmith on master

    Issue #268: Count aggregate on … (compare)

  • Oct 07 09:23
    MikeGoldsmith closed #273
  • Oct 07 00:18
    olee opened #275
  • Oct 06 17:58
    olee opened #274
  • Oct 05 17:52
    brantburnett commented #268
  • Oct 05 17:51
    brantburnett opened #273
  • Oct 04 17:38
    drubino commented #272
  • Oct 04 17:19
    brantburnett commented #272
  • Oct 04 16:05
    drubino commented #272
  • Oct 04 14:07
    brantburnett commented #272
  • Oct 04 13:59
    drubino opened #272
  • Oct 02 12:23
    MikeGoldsmith commented #268
Matthew D. Groves
@mgroves
@jrlawhorne you can setup filtering with XDCR if you only want certain documents replicated: https://docs.couchbase.com/server/6.0/manage/manage-xdcr/create-xdcr-replication.html
JR Lawhorne
@jrlawhorne
:thumbsup: That’s performed by regex on document key. Hmm. I doubt I’ll use that. It’s likely better to replicate all data everywhere in case I need to fail a region over to an alternate region.
In that case, the data would already be in the alternate region and I’d only need to tell the clients to use a different region.
Any region could serve any tenant/client but they’d have a default that should be fast.
Matthew D. Groves
@mgroves
yep
you got it :)
some companies need to/like to geofence and filter with XDCR
JR Lawhorne
@jrlawhorne
Hmm. I can see that if you’re global - prevent country data from crossing boundaries.
That’s an interesting thought.
@brantburnett you’re letting each of your models decide their own keys? I’m using GUIDs so at the moment, I’m planning to let DocumentBase take care of creating its own ID on construction. Am I breaking your beautiful architecture?
JR Lawhorne
@jrlawhorne
Something like:
        public DocumentBase()
        {
            Id =  GetKeyIdPrefix(Service, Type, Tenant) + Guid.NewGuid().ToString("N");
        }
Brant Burnett
@brantburnett
@jrlawhorne That approach has some issues. First of all, Guid.NewGuid() will be called for every construction, including deserialization when you read docs back out, so it's a bit of a performance hit
here's how I normally write a document class:
[DocumentTypeFilter(TypeString)]
public class MyDocument : DocumentBase
{
    public const string ServiceString = "mysvc";
    public const string TypeString = "mytype";

    public string Service => ServiceString;
    public string Type => TypeString;
    public string KeyId => GetKey(Id);

    public Guid Id { get; set;}

    public static string GetKey(Guid id) {
        return GetKeyPrefix(ServiceString, TypeString) + id.ToString("N");
    }
}
this gives a static method to build the key for getting documents by primary key, and also stores the key in the document itself so that it deserializes back out again on gets
Brant Burnett
@brantburnett
there's some redundant data (keyId in doc and metadata, plus the GUID in id), but Couchbase is all about denormalization anyway :)
JR Lawhorne
@jrlawhorne
:thumbsup: brb - I did consider storing the ID in the document. Thought I was crazy. lol
Brant Burnett
@brantburnett
only requirement is that you must initialize Id before save for new documents
JR Lawhorne
@jrlawhorne
@brantburnett The Guid Id is the only one stored in the document, correct? Then, the KeyId is the actual document ID in CB which can be be reconstructed using the Guid.
Brant Burnett
@brantburnett
i generally include both
but you could throw [JsonIgnore()] on KeyId so it doesn't store it
@jrlawhorne
JR Lawhorne
@jrlawhorne
Gotcha. Thanks! I’m re-engineering a bit with my multi-tenancy requirement plus the flurry of discussion about XDCR filtering. I’m thinking a document key of: ZONE:TenantID-Service-Type-DocumentID
Then, if I need to limit the data replication, I can filter on the ZONE at the front of the key. I need to build in protections on the TenantID to prevent data from tenant A syncing to tenant B. The rest is what you have I think.
Really appreciate you sharing your model - it’s helping a lot.
Brant Burnett
@brantburnett
glad to help
JR Lawhorne
@jrlawhorne
@brantburnett What does the [Key] annotation buy you in the DocumentBase?
Brant Burnett
@brantburnett
if you're using the change tracking features of the LINQ provider, it let's it know where to get the ID for new documents
JR Lawhorne
@jrlawhorne
gotcha. So, that should be the full CB ID
Brant Burnett
@brantburnett
yes
JR Lawhorne
@jrlawhorne
:thumbsup:
Matthew D. Groves
@mgroves
"'Subqueries In The Main From Clause Are Only Supported For Grouping And Unions'", what does that mean?
Brant Burnett
@brantburnett
lol, yeah that one's a bit confusing
basically, at least prior to CB Server 5.5, you couldn't just write a subquery and have it in the FROM clause of the main query as a data source
so, that error is thrown when the query you are writing would need to do that
Matthew D. Groves
@mgroves
hmm
Brant Burnett
@brantburnett
grouping and unions is a side case where the query appears to need that, but we can write it in a different way in N1QL instead
Matthew D. Groves
@mgroves
I don't feel like the query I'm trying should do that
but I could be wrong
it's 4 wheres, a skip, a take
is the skip/take wrapping a subquery?
Brant Burnett
@brantburnett
yeah, something simple like that probably wouldn't
can you get me the overall query syntax in C#?
Matthew D. Groves
@mgroves
        var results = _bucketContext.Query<User>()
            .Where(u => u.Type == "user")
            .Where(u => u.FirstName.ToLower() == firstName.ToLower())
            .Where(u => u.Enabled == enabled)
            .Where(u => u.CountryCode == countryCode)
            .Skip(offset)
            .Take(limit)
            .Select(u => new { key = N1QlFunctions.Meta(u).Id, document = u })
            .ToList();
Brant Burnett
@brantburnett
the issue is doing the projection after skip/take
Matthew D. Groves
@mgroves
I thought maybe the ToLower was screwing it up, so I took that out, same error
DOH
of course :)
thank you
Jeffry Morris
@jeffrymorris
@/all Linq2Couchbase 1.4.1 is now available on Nuget: https://www.nuget.org/packages/Linq2Couchbase/1.4.1