Pull request review commentfauna/faunadb-js
DRV-369: get rid of util nodejs package
'use strict' +/**+ * Inherit the prototype methods from one constructor into another.+ * @param {function} ctor Constructor function which needs to inherit the prototype.+ * @param {function} superCtor Constructor function to inherit prototype from.+ * @private+ */+function inherits(ctor, superCtor) {
Added link to polyfill repo
comment created time in 3 hours
Pull request review commentfauna/faunadb-js
DRV-369: get rid of util nodejs package
'use strict' +/**+ * Inherit the prototype methods from one constructor into another.+ * @param {function} ctor Constructor function which needs to inherit the prototype.+ * @param {function} superCtor Constructor function to inherit prototype from.+ * @private+ */+function inherits(ctor, superCtor) {+ if (ctor === undefined || ctor === null) {+ throw new TypeError(+ 'The constructor to "inherits" must not be ' + 'null or undefined'
Thanks for pointing, removed unnecessary concatenation
comment created time in 3 hours
push eventfauna/faunadb-js
commit sha 630317d5063007061d12428347a000cd781d4401
DRV-369: get rid of util nodejs package
push time in 3 hours
Pull request review commentfauna/faunadb-js
DRV-369: get rid of util nodejs package
'use strict' +/**+ * Inherit the prototype methods from one constructor into another.+ * @param {function} ctor Constructor function which needs to inherit the prototype.+ * @param {function} superCtor Constructor function to inherit prototype from.+ * @private+ */+function inherits(ctor, superCtor) {
Was this polyfill copied from somewhere? If so, could you add a link to it in the function docs?
comment created time in 4 hours
Pull request review commentfauna/faunadb-js
DRV-369: get rid of util nodejs package
'use strict' +/**+ * Inherit the prototype methods from one constructor into another.+ * @param {function} ctor Constructor function which needs to inherit the prototype.+ * @param {function} superCtor Constructor function to inherit prototype from.+ * @private+ */+function inherits(ctor, superCtor) {+ if (ctor === undefined || ctor === null) {+ throw new TypeError(+ 'The constructor to "inherits" must not be ' + 'null or undefined'
(there's two more occurrences bellow)
comment created time in 4 hours
Pull request review commentfauna/faunadb-js
DRV-369: get rid of util nodejs package
'use strict' +/**+ * Inherit the prototype methods from one constructor into another.+ * @param {function} ctor Constructor function which needs to inherit the prototype.+ * @param {function} superCtor Constructor function to inherit prototype from.+ * @private+ */+function inherits(ctor, superCtor) {+ if (ctor === undefined || ctor === null) {+ throw new TypeError(+ 'The constructor to "inherits" must not be ' + 'null or undefined'
What's the reason for the concatenation here?
comment created time in 4 hours
Pull request review commentfauna/faunadb-js
Fix for stringification to FQL which inserted nulls for zero-argument AND expose toFQL
var exprToString = function(expr, caller) { var fn = keys[0] fn = convertToCamelCase(fn) - var args = keys.map(function(k) {+ var args = []++ keys.forEach(function(k) {
I would probably, do it as:
keys .filter(function(k) { return expr[k] !== null }) .map(function(k) { return exprToString(v, fn) })
but it can be a matter of preference anyway.
comment created time in 6 hours
issue closedfauna/faunadb-csharp
I would like to know whether there would ever be a faunadb extension for EFcore since it's one of the main ways that people manipulate databases in .Net
closed time in 7 hours
Dedigrazissue commentfauna/faunadb-csharp
Hi @Dedigraz, this is something we've discussed putting on our roadmap in the future. Please feel free to post this request in our Forums' "feature request" category https://forums.fauna.com/c/feature-requests/2
comment created time in 8 hours
PR opened fauna/faunadb-js
Notes
Jira Ticket
NodeJS util
package has been used for .inherits
and .inspect
functions. Current implementation supposes polyfilling .inherits
function by created one in src/_util.js
and optionally using .inspect
only when we're running on NodeJS environment
How to test
No features / fixes have been introduced. Can be tested regression-wise
pr created time in 11 hours
create barnchfauna/faunadb-js
branch : DRV-369/get-rid-of-util-package
created branch time in 11 hours
issue openedfauna/faunadb-csharp
I would like to know whether there would ever be a faunadb extension for EFcore since it's one of the main ways that people manipulate databases in .Net
created time in 16 hours
pull request commentfauna/faunadb-js
Fix FaunaDate test to ignore timezone
@erickpintor here is where FaunaTime transforms Date instance to iso string. so here is what i get
new Date(1970, 0, 1).toISOString()
"1969-12-31T21:00:00.000Z"
comment created time in 3 days
pull request commentfauna/faunadb-js
Fix FaunaDate test to ignore timezone
I'm surprised to see this test failing now since we've had folks in different timezones workin on the JS driver before. Do we know which part of the driver is rendering the wrong timezone? I don't oppose the fix. I'm just wondering what's the root cause.
comment created time in 3 days
PR opened fauna/faunadb-js
Notes
Jira Ticket
Current driver pass a 60 seconds timeout down to the cross-fetch
polyfill. However, neither whatwg-fetch
of node-fetch
are aware of it. They both support abort signals, though: https://github.com/node-fetch/node-fetch#request-cancellation-with-abortsignal.
Screenshots
pr created time in 3 days
PR opened fauna/faunadb-js
Notes
Test "Values › date" doesn't respect timezone
Actual result
Values › date
expect(received).toEqual(expected) // deep equality
Expected: "{\"@date\":\"1970-01-01\"}"
Received: "{\"@date\":\"1969-12-31\"}"
86 | var test_date = new FaunaDate(new Date(1970, 0, 1))
87 | var test_date_json = '{"@date":"1970-01-01"}'
> 88 | expect(json.toJSON(test_date)).toEqual(test_date_json)
| ^
89 | expect(json.parseJSON(test_date_json)).toEqual(test_date)
90 | })
91 |
at Object.test (test/values.test.js:88:36)
Expected result
Test should be passed
How to test
jest --env=node --verbose=false ./test/values.test.js
pr created time in 4 days
pull request commentfauna/faunadb-go
DRV-368: Added support for omitempty field tag
I added a WIP of sucessfully decoding omitempty structs.
This however caused another test to fail:
TestRunClientTests/TestEvalCountMeanSumExpression
Probably need someone with more intricate knowledge of the FQL language and serialization/deserialization to finish and fix this
comment created time in 4 days
pull request commentfauna/faunadb-go
DRV-368: Added support for omitempty field tag
tests and fixes for deserialization still needed, will get that one of the next days
comment created time in 4 days
issue commentfauna/faunadb-go
Fauna-go should ignore zero values when serializing/saving
Update: Option 1 above doesnt work either, as a pointer string field with nil value, will override and delete any existing data in the field, possibly causing unintended dataloss:
Example:
//Struct
person := &Person{
Name: &name,
Email: &email,
}
personObj := f.Obj{"data":&person}a
fmt.Println(personObj.String())
// prints: 'Obj{"data": Obj{"Name": "John Doe", "Email": "somemail@mail.com"}}'
newEmail := "newemail@mail.com"
personEmailOnly := &Person{
Email: &newEmail,
}
personEmailOnlyObj := f.Obj{"data":&personEmailOnly}
fmt.Println(personEmailOnlyObj.String())
// prints: 'Obj{"data": Obj{"Name": nil, "Email": "newemail@mail.com"}}'
res, err := s.fdb.Query(f.Create(f.Collection("persons"),personObj))
if err != nil {
return err
}
var personRef f.RefV
_ = res.At(ref).Get(&personRef)
res, err = s.fdb.Query(f.Update(personRef,personEmailOnlyObj))
if err != nil {
return err
}
newPerson := Person{}
res.At(data).Get(&newPerson)
fmt.Println("name:",newPerson.Name," | email: ",newPerson.Email)
// prints: 'name: <nil> | email: 0xc013cf2480
'
In the above case, we create a person with both email and name. Then afterwards we update the persons email, having a struct that has "nil" at the Name field. This causes as the resulting value in the name field in the database to be deleted.
comment created time in 4 days
issue commentfauna/faunadb-go
Fauna-go should ignore zero values when serializing/saving
Update: Option 1 above doesnt work either, as a pointer string field with nil value, will override and delete any existing data in the field, possibly causing unintended dataloss:
Example:
//Struct
person := &Person{
Name: &name,
Email: &email,
}
personObj := f.Obj{"data":&person}
fmt.Println(personObj.String())
newEmail := "newemail@mail.com"
personEmailOnly := &Person{
Email: &newEmail,
}
personEmailOnlyObj := f.Obj{"data":&personEmailOnly}
fmt.Println(personEmailOnlyObj.String())
res, err := s.fdb.Query(f.Create(f.Collection("persons"),personObj))
if err != nil {
return err
}
var personRef f.RefV
_ = res.At(ref).Get(&personRef)
res, err = s.fdb.Query(f.Update(personRef,personEmailOnlyObj))
if err != nil {
return err
}
newPerson := Person{}
res.At(data).Get(&newPerson)
fmt.Println("name:",newPerson.Name," | email: ",newPerson.Email)
In the above case, we create a person with both email and name. Then afterwards we update the persons email, having a struct that has "nil" at the Name field. This causes as the resulting value in the name field in the database to be deleted.
comment created time in 4 days
issue commentfauna/faunadb-go
Fauna-go should ignore zero values when serializing/saving
Another update on this issue, with details on a use case where pointers are not preferable is when updating existing structs:
Say I have a struct as follows
type Person struct {
Email string `fauna:"email"`
Name int `fauna:"name"`
}
Lets say I have strictly ensured that these columns are never null, and therefore I prefer to treat them as strings rather than pointers
Now I want to update a struct and change the email of a person. For example because I received a put request from the user. If this put object contained only the email, I would do the following:
If I pass in the customer struct like so:
myPerson := Person{Email: newEmail}
res, err := faunaClient.Query(f.Update(ref,&myPerson))
this would cause the Name field in the database to be overwritten with "", which is not I what I want.
Now am stuck with two options:
- model the fields as nullable, even though they are not nullable and never have zero values. Which causes we to introduce unnecessary nil checks in the rest of the code.
- manually create the FQL query for only updated a subset of the fields. This might be easy for the above struct, but imagine a large struct with hundreds of fields and nested objects where I only want to up date a single field, then it would be a tedious proces..
Implementing omitempty option elegantly solves this by never serializing and transmitting values that have zero values.
comment created time in 5 days
issue commentfauna/faunadb-js
Unable to import into Cloudflare Workers
Sorry about that! I meant reverting back the faunadb package to 3.0.0.
comment created time in 5 days
issue commentfauna/faunadb-js
Unable to import into Cloudflare Workers
In my case, after switching back to npm 3.0.0 the wrangler-cli can't even execute publish anymore. @jessepmason what OS are you on? Is it really npm v. 3 that works for you?
comment created time in 5 days
push eventfauna/faunadb-js
commit sha 06777483a2f0d4e8627b50fd01b54df4883c72aa
switch from contatenated to line-separated JSON
commit sha 2e64c305d0a84eb10ee7b3e9e06ac857c97fc7a1
Merge pull request #373 from fauna/fix-parser ENG-2431: Switch from contatenated to line-separated JSON
push time in 7 days
PR merged fauna/faunadb-js
Notes
To support for large JSON documents, we're moving from concatenated JSON objects to line-separated JSON streaming. This fix is intended to be backwards compatible while supporting the new line-separated format that is coming to cloud soon.
How to test
With a recent nightly build:
- Create a document;
- Open a stream for it;
- Issue an updated with a relatively large JSON document (about 4KB or more).
Without this fix, the JSON parsing on the received version should break. With this path, you shall receive the updated version normally as part of the document stream.
We should release this fix once ENG-2431 is in cloud.
pr closed time in 7 days
issue commentfauna/faunadb-python
Example Documentation for Lambdas
@faunaee Hi Ewan, thanks for your reply. Let's say I wanted to bulk create records. I attempted a loop create:
# for row in data: # result = client.query( # q.create( # q.collection(collection_name), # { # "data": row # } # ) # )
This worked, but for 100000 rows - is completely impractical. I'm perhaps bending FaunaDB to our whim, but how could a
Lambda()
work for this scenario? We haveq.lamda_
but also pythons inbuiltlambda
expressions...which do we use when and where? It's just not clear.
@asencis When reading data from a collection or index you can use the built in lambda function as below.
data = client.query(
# Maps over an array or FQL page and calls an expression/lambda on each item.
# In this case, we are calling q.get on each item returned from the 2nd parameter’s q.paginate.
q.map_(
# q.get takes a document’s Ref and retrieves the entire document.
# Refs are similar to primary/foreign keys and serve as unique pointers to documents.
# q.index returns the Ref for an index. Note that all entities in FaunaDB are documents and have Refs.
# q.match takes the ref of an index, along with search parameters, and returns something called a SetRef.
# Finally, q.paginate takes a SetRef and returns a page with iterable data.
lambda x: q.get(x),
q.paginate(q.match(
q.index("products_by_category"), category)))
)
comment created time in 9 days
issue openedfauna/faunadb-go
LICENSE file not detected correctly by new go doc site
The new documentation site for go (pkg.go.dev) does not detect the LICENSE file correctly, causing documenation to not be displayed.
Missing docs: https://pkg.go.dev/github.com/fauna/faunadb-go/v3/faunadb
The License is MPL-2.0, but somehow pkg.go.dev does not detect this.
More info: https://pkg.go.dev/license-policy
created time in 10 days
issue closedfauna/faunadb-csharp
[C#] Decoding of custom type in array returns NULL values
I have created a custom type called User, which utilises the FaunaField reflection method for specifying properties of the objects.
Please provide more information on how to decode arrays of custom types, as this id poorly described in your documentation for the C# driver.
The problem can be repreduced from the following example.
Example:
public class User
{
[FaunaField("id")]
public string Id { get; set; }
[FaunaField("name")]
public string Name { get; set; }
...
}
I then created a mutation for creating a new document in my 'user' collection, which works fine, and returns the expected result.
Example:
var result = await _fauna.client.Query(
Create(
Collection("user"),
Obj("data", Encoder.Encode(upsertUser))));
return Decoder.Decode<User>(result.At("data"));
Now my issue is retrieving the full list of user documents in my 'users' collection. I verified that i retrieve all the right data, but once i decode the data with Decoder.Decode or <<....>>.To<User[]>() i get NULL values.
Example:
public async Task<User[]> GetUser()
{
var result = await _fauna.client.Query(
Map(
Paginate(
Documents(Collection("user"))),
Lambda("X", Get(Var("X")))));
var userResult = result.At("data").To<User[]>().Value;
return userResult;
}
Raw Output:
Arr(
ObjectV(
ref: RefV(id = "286263727644213761",
collection = RefV(id = "user", collection = RefV(id = "collections"))),
ts: LongV(1609261214770000),
data: ObjectV(id: StringV(d9853632-7b8f-42d1-b217-eb314e58d417),
name: StringV(Test User),
email: StringV(sample@domain.email),
ObjectV(
ref: RefV(id = "286263756128780801",
collection = RefV(id = "user", collection = RefV(id = "collections"))),
ts: LongV(1609261241940000),
data: ObjectV(id: StringV(56a06ea3-ef0b-4ded-a627-ceab63385fe2),
name: StringV(Test User),
email: StringV(sample@domain.email),
)
)
Decoded Output:
{
"data": {
"user": [
{
"id": null,
"name": null,
"email": null,
"access": null
},
{
"id": null,
"name": null,
"email": null,
"access": null
}
]
}
}
Expected Output:
{
"data": {
"user": [
{
"id": "Sample ID",
"name": "Sample Name",
"email": "Sample Email",
},
{
"id": "Sample ID",
"name": "Sample Name",
"email": "Sample Email",
}
]
}
}
closed time in 11 days
CTxDissue commentfauna/faunadb-csharp
[C#] Decoding of custom type in array returns NULL values
@marrony - thanks for the quick response! Works as expected.
comment created time in 11 days